質問 > フロント機能 > 全てのレビューを表示させる方法について |
フロント機能
スレッド表示 | 古いものから | 前のトピック | 次のトピック | 下へ |
投稿者 | スレッド |
---|---|
habu |
投稿日時: 2011/2/4 11:18
対応状況: −−−
|
長老 登録日: 2006/9/15 居住地: 投稿: 282 |
Re: トップページに新規レビューを表示させたい sakurai07 さん
どこが間違っているかはちょっと分からなかったので、 手順をざっくりまとめてみました。 ※【追記】幾つか誤っている手順がありましたので、変更して投稿しなおしました。(修正部分を赤字にしています) 恐らく、問題になっているのは赤字で記している部分周りではないかと考えています。 よかったら、この手順に沿ってもう一度確認してみてください。 【Step.1】新着レビューブロックを作成 管理画面(デザイン管理→ブロック編集)から、 ・ブロック名:「NEW REVIEW」(←分かればなんでも良いが、後ほどphpMyAdminで確認する時に文字化けする場合があるので英語表記にしておく) ・ファイル名:「view」(view.tpl) としてブロックを新規作成。 ブロックの内容は、「新着情報」(news.tpl)を基に、以下の様にする。
【Step.2】view.phpの作成 クラスの名前を、以下の通り変更しています。 ・LC_Page_FrontParts_Bloc_view → LC_Page_FrontParts_Bloc_Review ・LC_Page_FrontParts_Bloc_view_Ex → LC_Page_FrontParts_Bloc_Review_Ex html/frontparts/bloc/news.phpをコピーして、 view.phpを作成し、内容を以下の通り変更する。 ■requireの変更
■利用するクラスの変更
【Step.3】(view.phpから読み込まれる)LC_Page_FrontParts_Bloc_Review_Ex.phpの作成 data/class_extends/page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_News_Ex.phpをコピーして LC_Page_FrontParts_Bloc_Review_Ex.phpを作成し、内容を以下の通り変更する。 ■requireの変更
■クラス定義の変更
【Step.4】(LC_Page_FrontParts_Bloc_Review_Ex.phpから読み込まれる)LC_Page_FrontParts_Bloc_Review.phpの作成 data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_news.phpをコピーして LC_Page_FrontParts_Bloc_Review.phpを作成し、内容を以下の通り変更する。 ■クラス定義の変更
■news.tpl→view.tpl
■lfGetNews() → lfGetReview()
■SQL変更(新着レビューを最大5件まで表示させる)
【Step.5】新着レビューブロックと、view.phpを結びつける DBのデータを変更するツール(phpMyAdminなど)を利用して、 「dtb_bloc」テーブルの、filenameが「view」(bloc_nameが「NEW REVIEW」)のレコードについて、 php_pathを「frontparts/bloc/view.php」にする。 これで、「NEW REVIEW」ブロック表示時に、以下のファイルが読み込まれる様になります。 html/frontparts/bloc/view.php 【Step.6】新着レビューブロックをページに配置する 管理画面(デザイン管理→レイアウト編集)で、「NEW REVIEW」ブロックをページに配置する。 以上です。 これで、新着レビューブロックを配置したページに、新着レビューが表示されると思います。
|
sakurai07 |
投稿日時: 2011/2/3 0:17
対応状況: −−−
|
長老 登録日: 2008/2/29 居住地: 投稿: 179 |
Re: トップページに新規レビューを表示させたい ■調べた結果
最初のデータに戻しまして、最初から順に試してみました。 最初の段階で間違っているようでした。 view.phpの <?php /* * This file is part of EC-CUBE * * Copyright(c) 2000-2010 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_PATH . "page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_News_Ex.php"); // }}} // {{{ generate page $objPage = new LC_Page_FrontParts_BLoc_News_Ex(); register_shutdown_function(array($objPage, "destroy")); $objPage->init(); $objPage->process(); ?> を、 require_once(CLASS_EX_PATH . "page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_View_Ex.php"); に変更した時点で、その下が表示されていませんでした。 LC_Page_FrontParts_Bloc_View_Ex.phpは、 LC_Page_FrontParts_Bloc_News_Ex.phpをコピーしたのですが、何か間違っているのでしょうか? アドバイス頂けたらすごく助かります。 宜しくお願いたします。 |
sakurai07 |
投稿日時: 2011/2/1 22:56
対応状況: −−−
|
長老 登録日: 2008/2/29 居住地: 投稿: 179 |
Re: トップページに新規レビューを表示させたい view.tplに
<!--{* * This file is part of EC-CUBE * * Copyright(c) 2000-2007 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="newsarea"> <h2><img src="<!--{$smarty.const.URL_DIR}-->img01/news.jpg" width="700" height="43" alt="新着情報" /></h2> <p>☆★☆ 新着情報は<a href="<!--{$smarty.const.URL_DIR}-->rss/index.php" target="_blank">RSS</a>で配信しています。★☆★</p> <!--{section name=data loop=$arrNews}--><dl> <dt><!--{$arrNews[data].review_date_disp|date_format:"%Y年%m月%d日"}--></dt> <dd> <!--{if $arrNews[data].news_url}--> <a href="<!--{$arrNews[data].news_url}-->" <!--{if $arrNews[data].link_method eq "2"}--> target="_blank" <!--{/if}-->> <!--{/if}--> <!--{$arrNews[data].title|escape|nl2br}--> <!--{if $arrNews[data].news_url}--> </a> <!--{/if}--><br /> <!--{$arrNews[data].comment|escape|nl2br}--> </dd> </dl> <!--{/section}--> </div> を、設定したのですが、何も変更されませんでした。 試しに、news.tplに <!--{* * This file is part of EC-CUBE * * Copyright(c) 2000-2007 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="newsarea"> <h2><img src="<!--{$smarty.const.URL_DIR}-->img01/news.jpg" width="700" height="43" alt="新着情報" /></h2> <p>☆★☆ 新着情報は<a href="<!--{$smarty.const.URL_DIR}-->rss/index.php" target="_blank">RSS</a>で配信しています。★☆★</p> <!--{section name=data loop=$arrNews}--><dl> <dt><!--{$arrNews[data].review_date_disp|date_format:"%Y年%m月%d日"}--></dt> <dd> <!--{if $arrNews[data].news_url}--> <a href="<!--{$arrNews[data].news_url}-->" <!--{if $arrNews[data].link_method eq "2"}--> target="_blank" <!--{/if}-->> <!--{/if}--> <!--{$arrNews[data].title|escape|nl2br}--> <!--{if $arrNews[data].news_url}--> </a> <!--{/if}--><br /> <!--{$arrNews[data].comment|escape|nl2br}--> </dd> </dl> <!--{/section}--> </div> を、入力すると、なんと変わったのですがすべて空白です。 データベースのphp_pathは下記になります。 27 ブロック名 bloc/view.tpl view 2011-01-31 14:47:23.500537 2011-01-31 19:44:03.079493 frontparts/bloc/view.php |
habu |
投稿日時: 2011/2/1 14:56
対応状況: −−−
|
長老 登録日: 2006/9/15 居住地: 投稿: 282 |
Re: トップページに新規レビューを表示させたい sakurai07さん
空の行が幾つか表示されたのではなく 新着情報が表示されたというのは解せないのですが、 気になった点をお伝えします。 引用:
↑で変更されたのは、view.tplでしょうか、 それとも、news.tplでしょうか。 これまで、news.tplを利用されるものと考えていたのですが、 data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_view.php の46行目付近で、
となっているので、 news.tplではなく、view.tplが変更されているか確認してみてください。
|
sakurai07 |
投稿日時: 2011/1/31 19:54
対応状況: −−−
|
長老 登録日: 2008/2/29 居住地: 投稿: 179 |
Re: トップページに新規レビューを表示させたい ご返信ありがとうございます。
設定してみましたが、新着情報が表示されてしまってしまいました。 管理画面のソースは下記になります。 <div id="newsarea"> <h2><img src="<!--{$smarty.const.URL_DIR}-->img01/news.jpg" width="700" height="43" alt="新着情報" /></h2> <p>☆★☆ 新着情報は<a href="<!--{$smarty.const.URL_DIR}-->rss/index.php" target="_blank">RSS</a>で配信しています。★☆★</p> <!--{section name=data loop=$arrNews}--><dl> <dt><!--{$arrNews[data].review_date_disp|date_format:"%Y年%m月%d日"}--></dt> <dd> <!--{if $arrNews[data].news_url}--> <!--{if $arrNews[data].link_method eq "2"}--> target="_blank" <!--{/if}-->> <!--{/if}--> <!--{$arrNews[data].title|escape|nl2br}--> <!--{$arrNews[data].title |escape|nl2br}--> href="<!--{$arrNews[data].news_url}-->" <!--{if $arrNews[data].link_method eq "2"}--> target="_blank" <!--{/if}-->> <!--{/if}--> <!--{$arrNews[data].title|escape|nl2br}--> <!--{if $arrNews[data].news_url}--> </a> <!--{/if}--><br /> <!--{$arrNews[data].comment|escape|nl2br}--> </dd> </dl> <!--{/section}--> </div> ■LC_Page_FrontParts_Bloc_view.php /httpdocs/data/class/pages/frontparts/bloc <?php /* * This file is part of EC-CUBE * * Copyright(c) 2000-2007 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_PATH . "pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php"); /** * 新着情報 のページクラス. * * @package Page * @author LOCKON CO.,LTD. * @version $Id:LC_Page_FrontParts_Bloc_News.php 15532 2007-08-31 14:39:46Z nanasess $ */ class LC_Page_FrontParts_Bloc_view extends LC_Page_FrontParts_Bloc { // }}} // {{{ functions /** * Page を初期化する. * * @return void */ function init() { parent::init(); $bloc_file = 'view.tpl'; $this->setTplMainpage($bloc_file); } /** * Page のプロセス. * * @return void */ function process() { if (defined("MOBILE_SITE") && MOBILE_SITE) { $objSubView = new SC_SiteView(); } else { $objSubView = new SC_MobileView(); } //新着レビュー取得 $this->arrNews = $this->lfGetReview(); $objSubView->assignobj($this); $objSubView->display($this->tpl_mainpage); } /** * モバイルページを初期化する. * * @return void */ function mobileInit() { $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "frontparts/" . BLOC_DIR . 'news.tpl'; } /** * Page のプロセス(モバイル). * * @return void */ function mobileProcess() { $this->process(); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } function lfGetReview(){ $conn = new SC_DBConn(); $sql = "SELECT *, cast(substring(create_date,1,10) as date) as review_date_disp FROM dtb_review WHERE del_flg = '0' AND status = '1' ORDER BY create_date DESC"; $list_data = $conn->getAll($sql); return $list_data; } } ?> ■LC_Page_FrontParts_Bloc_view_Ex.php /httpdocs/data/class_extends/page_extends/frontparts/bloc <?php /* * This file is part of EC-CUBE * * Copyright(c) 2000-2007 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_PATH . "pages/frontparts/bloc/LC_Page_FrontParts_Bloc_view.php"); /** * 新着情報 のページクラス(拡張). * * LC_Page_FrontParts_Bloc_News をカスタマイズする場合はこのクラスを編集する. * * @package Page * @author LOCKON CO.,LTD. * @version $Id: LC_Page_FrontParts_Bloc_News_Ex.php 16741 2007-11-08 00:43:24Z adachi $ */ class LC_Page_FrontParts_Bloc_view_Ex extends LC_Page_FrontParts_Bloc_view { // }}} // {{{ functions /** * Page を初期化する. * * @return void */ function init() { parent::init(); } /** * Page のプロセス. * * @return void */ function process() { parent::process(); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } } ?> ■view.php /httpdocs/frontparts/bloc <?php /* * This file is part of EC-CUBE * * Copyright(c) 2000-2007 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_PATH . "page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_view_Ex.php"); // }}} // {{{ generate page $objPage = new LC_Page_FrontParts_BLoc_view_Ex(); register_shutdown_function(array($objPage, "destroy")); $objPage->init(); $objPage->process(); ?> 間違った記述ありますでしょうか? ご指導宜しくお願いたします。 |
habu |
投稿日時: 2011/1/31 16:54
対応状況: −−−
|
長老 登録日: 2006/9/15 居住地: 投稿: 282 |
Re: トップページに新規レビューを表示させたい sakurai07さん
■LC_Page_FrontParts_Bloc_view.php の62,63行目は変更済みでしょうか?
↓
■また、管理画面「デザイン管理」→「ブロック編集」→news.tpl の中にある、 「$arrNews[data].news_date_disp」等の記述は変更済みでしょうか。 ----- ・news_date_disp → review_date_disp ・news_url → 必要なら、商品ページに遷移する様に変更 ・news_title → title ・news_comment → comment -----
|
sakurai07 |
投稿日時: 2011/1/31 15:16
対応状況: −−−
|
長老 登録日: 2008/2/29 居住地: 投稿: 179 |
Re: トップページに新規レビューを表示させたい 下記に設定してみましたが、設定したブロックからすべて白くなってしまいました。
なんどやっても失敗しています。ご指導お願い致します。 ■data/class/pages/frontparts/bloc/ LC_Page_FrontParts_Bloc_news.phpを複製して LC_Page_FrontParts_Bloc_view.phpに変更。 function lfGetNews(){ $conn = new SC_DBConn(); $sql = "SELECT *, cast(news_date as date) as news_date_disp FROM dtb_news WHERE del_flg = '0' ORDER BY rank DESC"; $list_data = $conn->getAll($sql); return $list_data; } を、 function lfGetReview(){ $conn = new SC_DBConn(); $sql = "SELECT *, cast(substring(create_date,1,10) as date) as review_date_disp FROM dtb_review WHERE del_flg = '0' AND status = '1' ORDER BY create_date DESC"; $list_data = $conn->getAll($sql); return $list_data; } に変更。 ■data/class_extends/page_extends/frontparts/bloc/ LC_Page_FrontParts_Bloc_News_Ex.phpを複製して LC_Page_FrontParts_Bloc_view_Ex.phpに変更 require_once(CLASS_PATH . "pages/frontparts/bloc/LC_Page_FrontParts_Bloc_News.php"); を、 require_once(CLASS_PATH . "pages/frontparts/bloc/LC_Page_FrontParts_Bloc_view.php");変更 ■html/user_data/packages/ 管理画面から、viewとして新規作成。 ■html/frontparts/bloc/ news.phpをview.phpに変更 require_once(CLASS_EX_PATH . "page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_News_Ex.php"); を require_once(CLASS_EX_PATH . "page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_view_Ex.php");に変更。 ■php_path frontparts/bloc/view.phpに設定。 |
sakurai07 |
投稿日時: 2011/1/24 18:07
対応状況: −−−
|
長老 登録日: 2008/2/29 居住地: 投稿: 179 |
Re: トップページに新規レビューを表示させたい ファイル複製して、myadminのphp_pathに複製ファイルを設定してみました。
管理画面のブロック管理で、下記のようにしたのですが、表示されず、管理画面の設定方法をご指導いただけませんでしょうか? <!--{* * This file is part of EC-CUBE * * Copyright(c) 2000-2007 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="newsarea"> <h2> <img src="<!--{$TPL_DIR}-->img/top/news.jpg" width="680" height="30" alt="新着情報" /> </h2> function lfGetReview(){ $conn = new SC_DBConn(); $sql = "SELECT *, cast(substring(create_date,1,10) as date) as review_date_disp FROM dtb_review WHERE del_flg = '0' AND status = '1' ORDER BY create_date DESC"; $list_data = $conn->getAll($sql); return $list_data; } </div> |
lumines |
投稿日時: 2011/1/13 16:54
対応状況: −−−
|
常連 登録日: 2007/4/27 居住地: 新潟 投稿: 39 |
Re: トップページに新規レビューを表示させたい データベースの「dtb_bloc」→「php_path」にパス指定しないとです。
複製は data/class/pages/frontparts/bloc/ data/class_extends/page_extends/frontparts/bloc/ html/user_data/packages/ html/frontparts/bloc/ 上記4つの箇所に必要です。
|
sakurai07 |
投稿日時: 2011/1/7 14:13
対応状況: −−−
|
長老 登録日: 2008/2/29 居住地: 投稿: 179 |
Re: トップページに新規レビューを表示させたい レビューにすごく興味ありまして、
function lfGetReview(){ $conn = new SC_DBConn(); $sql = "SELECT *, cast(substring(create_date,1,10) as date) as review_date_disp FROM dtb_review WHERE del_flg = '0' AND status = '1' ORDER BY create_date DESC"; $list_data = $conn->getAll($sql); return $list_data; } を、管理画面の新着情報ブロックを複製して、追加したら表示されるのでしょうか? 試してみて、何も表示されなかったです。 方法が間違っているようでしたら、ご指導いただけたら助かります。 EC-CUBEバージョン 2.4.4 PHPバージョン PHP 5.2.6 DBバージョン MySQL 5.1.34-log |
« 1 (2) 3 » |
スレッド表示 | 古いものから | 前のトピック | 次のトピック | トップ |