ECCUBEの学校『EC-CUBE2系のモバイルサイトでサムネイル表示をする。』
url:http://www.eccube-school.jp/products/detail55.html
を参考にして「/html/require.php」の
header(“Location: “. SC_Utils_Ex::sfRmDupSlash($url . $path));
exit;
を
/* resize_image.phpのときだけ、リダイレクト解除 */
if(!preg_match(“/resize_image.php/i”, $path)) {
header(“Location: “. SC_Utils_Ex::sfRmDupSlash($url . $path));
exit;
}
のように変更。
そして、画像を表示したい場所(別のファイルです。例えば「data/Smarty/templates/defalt/mobile/frontparts/bloc/best5.tpl」 など)に以下を記入します。
<!–{if $arrProduct.main_list_image != “”}–> <!–{assign var=image_path value=”`$arrProduct.main_list_image`”}–> <!–{else}–> <!–{assign var=image_path value=”`$smarty.const.NO_IMAGE_DIR`”}–> <!–{/if}–> <img src=”<!–{$smarty.const.SITE_URL}–>resize_image.php?image=<!–{$image_path|sfRmDupSlash}–>&width=50&height=50″ alt=”<!–{$arrProducts[cnt].name|escape}–>” /> |
を記入したら、モバイル画面に画像が表示されました。
記入例)
「data/Smarty/templates/defalt/mobile/frontparts/bloc/best5.tpl」の変更例(全文)
////////////////////////////////////////////
<!–{* /* * 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. */ *}–> <!–{if count($arrBestProducts) > 0}–> <center> <!–{foreach from=$arrBestProducts item=arrProduct name=best_products}–> <!– ▼オススメコメント ここから –> <a href=”<!–{$smarty.const.MOBILE_DETAIL_P_HTML}–><!–{$arrProduct.product_id}–>”> <!–{$arrProduct.name|escape|nl2br}–> <!–{if $arrProduct.main_list_image != “”}–> <!–{assign var=image_path value=”`$arrProduct.main_list_image`”}–> <!–{else}–> <!–{assign var=image_path value=”`$smarty.const.NO_IMAGE_DIR`”}–> <!–{/if}–> <img src=”<!–{$smarty.const.SITE_URL}–>resize_image.php?image=<!–{$image_path|sfRmDupSlash}–>&width=50&height=50″ alt=”<!–{$arrProducts[cnt].name|escape}–>” /> </a> <!– ▲オススメコメント ここまで –> <!–{if !$smarty.foreach.best_products.last}–><br><br><!–{/if}–> <!–{/foreach}–> </center> <!–{/if}–> |
///////////////////////////////////////////////
nameのところは元々はcomentだったと思いますが、名前を表示したくて変更しました。
以下部分が、新たに付け加えたところです。
<!–{if $arrProduct.main_list_image != “”}–>
<!–{assign var=image_path value=”`$arrProduct.main_list_image`”}–>
<!–{else}–>
<!–{assign var=image_path value=”`$smarty.const.NO_IMAGE_DIR`”}–>
<!–{/if}–>
<img src=”<!–{$smarty.const.SITE_URL}–>resize_image.php?image=<!–{$image_path|sfRmDupSlash}–>&width=50&height=50″ alt=”<!–{$arrProducts[cnt].name|escape}–>” />
コメント