トップページに新着情報ブロックというものがあります。
これは管理画面>コンテンツ管理>新着情報管理 に登録したものがブロック形式で表示されるのですが、
簡易ブログっぽく使いたいなと思い、とりあえず新着情報の詳細ページを30分以内で作ってみました。
非常に雑ですが、とりあえず表示はされると思います。ご利用は自己責任で。
1.html/news/detail.php を新規作成
<?php /* * This file is part of EC-CUBE * * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved. * * http://www.lockon.co.jp/ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // {{{ requires require_once '../require.php'; require_once CLASS_EX_REALDIR . 'page_extends/news/LC_Page_News_Detail_Ex.php'; // }}} // {{{ generate page $objPage = new LC_Page_News_Detail_Ex(); register_shutdown_function(array($objPage, "destroy")); $objPage->init(); $objPage->process(); ?>
2.data/class_extends/page_extends/news/LC_Page_News_Detail_Ex.php を新規作成
<?php /* * This file is part of EC-CUBE * * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved. * * http://www.lockon.co.jp/ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // {{{ requires require_once CLASS_REALDIR . 'pages/news/LC_Page_News_Detail.php'; /** * LC_Page_Products_Detail のページクラス(拡張). * * LC_Page_Products_Detail をカスタマイズする場合はこのクラスを編集する. * * @package Page * @author LOCKON CO.,LTD. * @version $Id: LC_Page_Products_Detail_Ex.php 20764 2011-03-22 06:26:40Z nanasess $ */ class LC_Page_News_Detail_Ex extends LC_Page_News_Detail { // }}} // {{{ functions /** * Page を初期化する. * * @return void */ function init() { parent::init(); } /** * Page のプロセス. * * @return void */ function process() { parent::process(); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } } ?>
3.data/class/pages/news/LC_Page_News_Detail.php を新規作成
<?php /* * This file is part of EC-CUBE * * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved. * * http://www.lockon.co.jp/ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // {{{ requires require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; /** * 商品詳細 のページクラス. * * @package Page * @author LOCKON CO.,LTD. * @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $ */ class LC_Page_News_Detail extends LC_Page_Ex { // }}} // {{{ functions /** * Page を初期化する. * * @return void */ function init() { parent::init(); } /** * Page のプロセス. * * @return void */ function process() { parent::process(); $this->action(); $this->sendResponse(); } /** * Page のAction. * * @return void */ function action() { // 会員クラス $objCustomer = new SC_Customer_Ex(); $objQuery = SC_Query_Ex::getSingletonInstance(); $col = '*'; $from = 'dtb_news'; $where = 'news_id = ? and del_flg = 0'; $arrval = array($_GET['news_id']); $arrNews = $objQuery->select($col, $from, $where, $arrval); $this->arrNews = $arrNews[0]; } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } } ?>
4.data/Smarty/templates/default/news/detail.tpl を新規作成
<!--{* * This file is part of EC-CUBE * * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved. * * http://www.lockon.co.jp/ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *}--> <div id="news_detail"> <h2>新着情報</h2> <!--▼CONTENTS--> <div id="undercolumn"> <!--{if count($arrNews) > 0}--> <ul> <li>news_id: <!--{$arrNews.news_id|u}--></li> <li>news_date: <!--{$arrNews.news_date|h}--></li> <li>rank: <!--{$arrNews.rank|u}--></li> <li>news_title: <!--{$arrNews.news_title|h}--></li> <li>news_comment: <!--{$arrNews.news_comment|h}--></li> <li>news_url: <!--{$arrNews.news_url|h}--></li> <li>news_select: <!--{$arrNews.news_select|h}--></li> <li>link_method: <!--{$arrNews.link_method|h}--></li> <li>creator_id: <!--{$arrNews.creator_id|u}--></li> <li>create_date: <!--{$arrNews.create_date|h}--></li> <li>update_date: <!--{$arrNews.update_date|h}--></li> </ul> <!--{else}--> 存在しないニュースです。 <!--{/if}--> </div> <!--▲CONTENTS--> </div><!--news_detail end-->
5.phpMyAdmin などにSQLを流します。既に新規ページを作成している場合は、2つ目の value は29ではないのでご注意。
insert into dtb_pagelayout values(10, 29, '新着情報詳細ページ', 'news/detail.php', 'news/detail', 1, 1, 1, 2,NULL, NULL, NULL, now(), now());
6./html/news/detail.php?news_id=1 などと、news_idを指定してあげれば、値が吐かれるはず。あとは適当にCSS等で味付けを。
ピンバック: [EC-CUBE 2.12.2] 新着情報一覧ページを作成 | NAKWEB × EC-CUBE