前回の「6)hetemlのサーバでEC-CUBEを使ってみる – 動的URLを静的URLに変更する(PCサイト)」で、PCサイトの静的化はできましたが、パラメータ設定で「P_DETAIL_URLPATH」のパスを変更しているので、スマフォではリンク切れをしていると思いますので、スマフォの対応もしたいと思います。
テンプレート(.tpl)のURLを静的に変更する
変更したテンプレート(.tpl)ファイルのサンプルをダウンロードおすすめ商品情報(TOP)
/data/Smarty/templates/originalSP/frontparts/bloc/recommend.tpl.product_id|u}–>の後に「.html」を追加する
<h3><a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrBestProducts[cnt].product_id|u}-->"><!--{$arrBestProducts[cnt].name|h}--></a></h3> ↓↓変更↓↓ <h3><a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrBestProducts[cnt].product_id|u}-->.html"><!--{$arrBestProducts[cnt].name|h}--></a></h3> <h3><a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrBestProducts[$cnt2].product_id|u}-->"><!--{$arrBestProducts[$cnt2].name|h}--></a></h3> ↓↓変更↓↓ <h3><a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrBestProducts[$cnt2].product_id|u}-->.html"><!--{$arrBestProducts[$cnt2].name|h}--></a></h3>
カテゴリブロック
/data/Smarty/templates/originalSP/frontparts/bloc/category.tplproducts/list.php?category_id=<!–{$arrTree[cnt].category_id}–>
を
products/list<!–{$arrTree[cnt].category_id}–>.html
に変更する
<a rel="external" href="<!--{$smarty.const.ROOT_URLPATH}-->products/list.php?category_id=<!--{$arrTree[cnt].category_id}-->"<!--{if in_array($arrTree[cnt].category_id, $tpl_category_id)}--> class="onlink"<!--{/if}-->> ↓↓変更↓↓ <a rel="external" href="<!--{$smarty.const.ROOT_URLPATH}-->products/list<!--{$arrTree[cnt].category_id}-->.html"<!--{if in_array($arrTree[cnt].category_id, $tpl_category_id)}--> class="onlink"<!--{/if}-->>
商品一覧ページ
/data/Smarty/templates/originalSP/products/list.tpl<!–{$arrProduct.product_id|u}–>の後に「.html」を追加する
<h3><a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->" name="product<!--{$arrProduct.product_id}-->" class="productName"><!--{$arrProduct.name|h}--></a></h3> ↓↓変更↓↓ <h3><a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrProduct.product_id|u}-->.html" name="product<!--{$arrProduct.product_id}-->" class="productName"><!--{$arrProduct.name|h}--></a></h3>
商品詳細ページ
/data/Smarty/templates/originalSP/products/detail.tpl関連カテゴリー
list.php?category_id=<!–{$arrRelativeCat[r][s].category_id}–>
を
list<!–{$arrRelativeCat[r][s].category_id}–>.html
に変更する
<a rel="external" href="<!--{$smarty.const.ROOT_URLPATH}-->products/list.php?category_id=<!--{$arrRelativeCat[r][s].category_id}-->"><!--{$arrRelativeCat[r][s].category_name}--></a> ↓↓変更↓↓ <a rel="external" href="<!--{$smarty.const.ROOT_URLPATH}-->products/list<!--{$arrRelativeCat[r][s].category_id}-->.html"><!--{$arrRelativeCat[r][s].category_name}--></a>
おすすめ商品
<!–{$arrRecommend[cnt].product_id|u}–>の後に「.html」を追加する
<h3><a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrRecommend[cnt].product_id|u}-->"><!--{$arrRecommend[cnt].name|h}--></a></h3> ↓↓変更↓↓ <h3><a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrRecommend[cnt].product_id|u}-->.html"><!--{$arrRecommend[cnt].name|h}--></a></h3>
MYページ 購入履歴詳細
/test/data/Smarty/templates/originalSP/mypage/history.tpl<!–{$orderDetail.product_id|u}–>の後に「.html」を追加する
<p><em><!--→商品名--><a<!--{if $orderDetail.enable}--> href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$orderDetail.product_id|u}-->"<!--{/if}--> rel="external"><!--{$orderDetail.product_name|h}--></a><!--←商品名--></em></p> ↓↓変更↓↓ <p><em><!--→商品名--><a<!--{if $orderDetail.enable}--> href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$orderDetail.product_id|u}-->.html"<!--{/if}--> rel="external"><!--{$orderDetail.product_name|h}--></a><!--←商品名--></em></p>
MYページ お気に入り一覧
/test/data/Smarty/templates/originalSP/mypage/favorite.tpl<!–{$product_id|u}–>の後に「.html」を追加する
<a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$product_id|u}-->"> ↓↓変更↓↓ <a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$product_id|u}-->.html"> <h4><a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$product_id|u}-->" class="productName"><!--{$arrFavorite[cnt].name}--></a></h4> ↓↓変更↓↓ <h4><a rel="external" href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$product_id|u}-->.html" class="productName"><!--{$arrFavorite[cnt].name}--></a></h4>
※変更は以上ですが抜けがあったら随時更新します。
その他に新規で作ったページなどがあったらこちらも同様に変更してください。
⇒7)PHP(php.ini)の設定例-hetemlのサーバでEC-CUBE(2.11.3)を使ってみる
⇒hetemlのサーバでEC-CUBEインストール~公開までの道のり
はじめまして。
質問させていただきます。
スマホサイトの商品一覧で「もっと見る」をクリックして現れた商品のリンクに.htmlが付かずNOT FOUNDになってしまいます。
この現象解決にはどのTPLファイルを更新すれば良いのでしょうか?
>ヒラカワさん
返信大変遅くなってすみません。
またご指摘ありがとうございます。
サイトを見たら対応できているようでしたので
問題ないと思いますが、備忘的に対処法残しておきます。
/data/Smarty/templates/originalSP/products/list.tpl
205行目付近
$($(“.list_area a.productName”).get(maxCnt)).attr(“href”, url + product.product_id);
↓↓↓ 【+ “.html”】を追加
$($(“.list_area a.productName”).get(maxCnt)).attr(“href”, url + product.product_id + “.html”);
で大丈夫です。