Labo

[EC-CUBE 2.12.2] 新着情報詳細ページを作成

2012年11月18日 / 投稿者名:fukap


トップページに新着情報ブロックというものがあります。
これは管理画面>コンテンツ管理>新着情報管理 に登録したものがブロック形式で表示されるのですが、
簡易ブログっぽく使いたいなと思い、とりあえず新着情報の詳細ページを30分以内で作ってみました。
非常に雑ですが、とりあえず表示はされると思います。ご利用は自己責任で。

 

1.html/news/detail.php を新規作成

1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23 
24// {{{ requires
25require_once '../require.php';
26require_once CLASS_EX_REALDIR . 'page_extends/news/LC_Page_News_Detail_Ex.php';
27 
28// }}}
29// {{{ generate page
30 
31$objPage = new LC_Page_News_Detail_Ex();
32register_shutdown_function(array($objPage, "destroy"));
33$objPage->init();
34$objPage->process();
35?>

2.data/class_extends/page_extends/news/LC_Page_News_Detail_Ex.php を新規作成

1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23 
24// {{{ requires
25require_once CLASS_REALDIR . 'pages/news/LC_Page_News_Detail.php';
26 
27/**
28 * LC_Page_Products_Detail のページクラス(拡張).
29 *
30 * LC_Page_Products_Detail をカスタマイズする場合はこのクラスを編集する.
31 *
32 * @package Page
33 * @author LOCKON CO.,LTD.
34 * @version $Id: LC_Page_Products_Detail_Ex.php 20764 2011-03-22 06:26:40Z nanasess $
35 */
36class LC_Page_News_Detail_Ex extends LC_Page_News_Detail {
37 
38    // }}}
39    // {{{ functions
40 
41    /**
42     * Page を初期化する.
43     *
44     * @return void
45     */
46    function init() {
47        parent::init();
48    }
49 
50    /**
51     * Page のプロセス.
52     *
53     * @return void
54     */
55    function process() {
56        parent::process();
57    }
58 
59    /**
60     * デストラクタ.
61     *
62     * @return void
63     */
64    function destroy() {
65        parent::destroy();
66    }
67}
68?>

3.data/class/pages/news/LC_Page_News_Detail.php を新規作成

1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23 
24// {{{ requires
25require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
26 
27/**
28 * 商品詳細 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $
33 */
34class LC_Page_News_Detail extends LC_Page_Ex {
35 
36    // }}}
37    // {{{ functions
38 
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46    }
47 
48    /**
49     * Page のプロセス.
50     *
51     * @return void
52     */
53    function process() {
54        parent::process();
55        $this->action();
56        $this->sendResponse();
57    }
58 
59    /**
60     * Page のAction.
61     *
62     * @return void
63     */
64    function action() {
65        // 会員クラス
66        $objCustomer = new SC_Customer_Ex();
67 
68        $objQuery = SC_Query_Ex::getSingletonInstance();
69        $col = '*';
70        $from = 'dtb_news';
71        $where = 'news_id = ? and del_flg = 0';
72        $arrval = array($_GET['news_id']);
73        $arrNews = $objQuery->select($col, $from, $where, $arrval);
74        $this->arrNews = $arrNews[0];
75    }
76 
77    /**
78     * デストラクタ.
79     *
80     * @return void
81     */
82    function destroy() {
83        parent::destroy();
84    }
85 
86}
87?>

4.data/Smarty/templates/default/news/detail.tpl を新規作成

1<!--{*
2 * This file is part of EC-CUBE
3 *
4 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
5 *
6 * http://www.lockon.co.jp/
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 *}-->
22 
23<div id="news_detail">
24 
25<h2>新着情報</h2>
26 
27<!--▼CONTENTS-->
28<div id="undercolumn">
29    <!--{if count($arrNews) > 0}-->
30    <ul>
31        <li>news_id: <!--{$arrNews.news_id|u}--></li>
32        <li>news_date: <!--{$arrNews.news_date|h}--></li>
33        <li>rank:  <!--{$arrNews.rank|u}--></li>
34        <li>news_title:  <!--{$arrNews.news_title|h}--></li>
35        <li>news_comment:  <!--{$arrNews.news_comment|h}--></li>
36        <li>news_url: <!--{$arrNews.news_url|h}--></li>
37        <li>news_select: <!--{$arrNews.news_select|h}--></li>
38        <li>link_method: <!--{$arrNews.link_method|h}--></li>
39        <li>creator_id: <!--{$arrNews.creator_id|u}--></li>
40        <li>create_date: <!--{$arrNews.create_date|h}--></li>
41        <li>update_date: <!--{$arrNews.update_date|h}--></li>
42    </ul>
43    <!--{else}-->
44        存在しないニュースです。
45    <!--{/if}-->
46</div>
47<!--▲CONTENTS-->
48 
49 
50 
51</div><!--news_detail end-->

5.phpMyAdmin などにSQLを流します。既に新規ページを作成している場合は、2つ目の value は29ではないのでご注意。

1insert 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] 新着情報詳細ページを作成 への1件のコメント

  1. ピンバック: [EC-CUBE 2.12.2] 新着情報一覧ページを作成 | NAKWEB × EC-CUBE

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

* Copy This Password *

* Type Or Paste Password Here *

*

コメント欄にコードを挿入したい場合は、[php][/php] を使ってください。