Last active
August 29, 2015 14:23
-
-
Save kurozumi/6023851a8cba75f73a9f to your computer and use it in GitHub Desktop.
【EC-CUBE】SC_Helper_Transformを使って商品詳細ページの文言を修正する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* This file is part of EC-CUBE | |
* | |
* Copyright(c) 2000-2014 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. | |
*/ | |
require_once CLASS_REALDIR . 'pages/products/LC_Page_Products_Detail.php'; | |
/** | |
* LC_Page_Products_Detail のページクラス(拡張). | |
* | |
* LC_Page_Products_Detail をカスタマイズする場合はこのクラスを編集する. | |
* | |
* @package Page | |
* @author LOCKON CO.,LTD. | |
* @version $Id: LC_Page_Products_Detail_Ex.php 23546 2014-06-12 14:47:59Z shutta $ | |
*/ | |
class LC_Page_Products_Detail_Ex extends LC_Page_Products_Detail { | |
/** | |
* Page を初期化する. | |
* | |
* @return void | |
*/ | |
function init() | |
{ | |
parent::init(); | |
$objHelperPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg); | |
$objHelperPlugin->addAction('outputfilterTransform', function(&$source, LC_Page_Ex $objPage) { | |
if (strpos($objPage->tpl_mainpage, 'detail.tpl')) { | |
$objTransform = new SC_Helper_Transform_Ex($source); | |
$this->lfTransfromProductName($objTransform, $objPage); | |
$source = $objTransform->getHTML(); | |
} | |
}); | |
} | |
/** | |
* Page のプロセス. | |
* | |
* @return void | |
*/ | |
function process() | |
{ | |
parent::process(); | |
} | |
/** | |
* 商品名を変更 | |
* | |
* @param type $objTransform | |
* @param LC_Page_Ex $objPage | |
*/ | |
public function lfTransfromProductName(&$objTransform, LC_Page_Ex $objPage) | |
{ | |
switch ($objPage->arrPageLayout['device_type_id']) { | |
case DEVICE_TYPE_PC: | |
$objTransform->select('#detailrightbloc h2')->replaceElement("<h2>商品名は{$objPage->arrProduct['name']}です。</h2>"); | |
break; | |
case DEVICE_TYPE_SMARTPHONE: | |
$objTransform->select('#detailarea h3.product_name')->replaceElement("<h3 class=\"product_name\">商品名は{$objPage->arrProduct['name']}です。</h3>"); | |
break; | |
default: | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment