Create a page news detail in ec-cube 2.12.x

LANGUAGES PHP TECHNOLOGY

Posted on 2015-07-03 10:30:44


Step by step for create a new page detail news in ec-cube

 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-->

Five. It will shed SQL etc. phpMyAdmin. If you already have created a new page, so the second value is not a 29 Notes.

INSERT INTO `c1eccube`.`dtb_pagelayout` (`device_type_id`, `page_id`, `page_name`, `url`, `filename`, `header_chk`, `footer_chk`, `edit_flg`, `author`, `description`, `keyword`, `update_url`, `create_date`, `update_date`) VALUES ('10', '32', 'news', 'news/detail.php', 'news/detail', '1', '1', '1', NULL, NULL, NULL, NULL, CURRENT_TIMESTAMP, '0000-00-00 00:00:00');  

6. and such /html/news/detail.php?news_id=1, to be rewarded by specifying the news_id, should the value is induce vomiting. And a suitably seasoned with CSS, etc. after.

 

  news_detail  

 

 By  tutscode.com