バージョン選択

フォーラム

メニュー

オンライン状況

29 人のユーザが現在オンラインです。 (19 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 29
もっと...

サイト内検索

質問 > フロント機能 > サイトマップページの作成

フロント機能

新規スレッドを追加する

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
Yasuhiro
投稿日時: 2010/1/12 18:07
対応状況: −−−
半人前
登録日: 2010/1/12
居住地: 新宿区
投稿: 22
Re: サイトマップページの作成
参考URLを拝見させて頂きましたが、情報が無いように思えます。
正しいURLを教えて貰えないでしょうか?


----------------
Yasuhiro Suzuki
http://www.nishi-shinjuku.net/

seasoft
投稿日時: 2010/1/12 18:13
対応状況: −−−
登録日: 2008/6/4
居住地:
投稿: 7367
Re: サイトマップページの作成
引用:

Yasuhiroさんは書きました:
参考URLを拝見させて頂きましたが、情報が無いように思えます。
正しいURLを教えて貰えないでしょうか?


zibaj 様の参照先ページ本文中の「Download」というリンク文字列から参照しているのでは?
ソースは未確認ですが、MT WordPress だけでなく EC-CUBE でも参考になりそうという事ではないでしょうか?

何の「初心者」なのか分かりませんが、PHP の初心者という事ですと、難しいかも。


----------------
Seasoft
こちらでの投稿は、アイディア程度に留めさせていただいております。
個別案件の作業は有償で承っております。お気軽にご相談ください。

tao_s
投稿日時: 2010/1/12 21:22
対応状況: −−−
仙人
登録日: 2008/8/20
居住地: 東京
投稿: 799
Re: サイトマップページの作成
tao_s
投稿日時: 2010/1/13 4:17
対応状況: −−−
仙人
登録日: 2008/8/20
居住地: 東京
投稿: 799
Re: サイトマップページの作成
と言う事で作ってみました。

商品詳細ページまで含めると大変な事になるので、商品ページはカテゴリまで(カテゴリブロックからソースを拝借して)作りました。

http://eccube-customize.xross-cube.com/sitemap/index.php


----------------
EC-CUBEカスタマイズ相談してください。
緊急のEC-CUBEの障害対応
EC-CUBEカスタマイズブログ

Yasuhiro
投稿日時: 2010/1/13 12:31
対応状況: −−−
半人前
登録日: 2010/1/12
居住地: 新宿区
投稿: 22
Re: サイトマップページの作成
まさしく、これがやりたかったのです。
たいへん厚かましいのですが、手順とかソースを拝見させて頂けないでしょうか?


----------------
Yasuhiro Suzuki
http://www.nishi-shinjuku.net/

tao_s
投稿日時: 2010/1/13 14:57
対応状況: −−−
仙人
登録日: 2008/8/20
居住地: 東京
投稿: 799
Re: サイトマップページの作成
引用:
たいへん厚かましいのですが、手順とかソースを拝見させて頂けないでしょうか?


手順に関しては先の書き込みのURLを参照願います。


----------------
EC-CUBEカスタマイズ相談してください。
緊急のEC-CUBEの障害対応
EC-CUBEカスタマイズブログ

Yasuhiro
投稿日時: 2010/1/13 18:49
対応状況: −−−
半人前
登録日: 2010/1/12
居住地: 新宿区
投稿: 22
Re: サイトマップページの作成
以下の手順で、サイトマップページを作成しようとしていますが、商品カテゴリの表示のみ上手く行きません。
どこが悪いのでしょうか?

1.呼出用ファイル作成
/html/sitemap/index.php
/data/class_extends/pages/sitemap/LC_Page_Sitemap_Ex.php
/data/class/pages/sitemap/LC_Page_Sitemap.php

2.DBの変更
dtb_pagelayoutにサイトマップを追加

3.LC_Page_Sitemap.phpのソース
<?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/LC_Page.php");

/**
* サイトマップ のページクラス.
*
* @package Page
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Entry_Kiyaku.php 16741 2007-11-08 00:43:24Z adachi $
*/
class LC_Page_Sitemap extends LC_Page {

// {{{ properties

/** ページナンバー */
var $tpl_pageno;

// }}}
// {{{ functions

/**
* Page を初期化する.
*
* @return void
*/
function init() {
parent::init();
$this->tpl_mainpage = 'sitemap/index.tpl';
$this->tpl_title = "サイトマップ";
}

/**
* Page のプロセス.
*
* @return void
*/
function process() {

$objView = new SC_SiteView();
$objQuery = new SC_Query();
$objCustomer = new SC_Customer();

// レイアウトデザインを取得
$objLayout = new SC_Helper_PageLayout_Ex();
$objLayout->sfGetPageLayout($this, false, "sitemap/index.php");

$objView->assignobj($this);
$objView->display(SITE_FRAME);
}

/**
* モバイルページを初期化する.
*
* @return void
*/
function mobileInit() {
$this->init();
}

/**
* Page のプロセス(モバイル).
*
* @return void
*/
function mobileProcess() {
$objView = new SC_MobileView();
$objCustomer = new SC_Customer();

$offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
$next = $offset;

// レイアウトデザインを取得
$objLayout = new SC_Helper_PageLayout_Ex();
$objLayout->sfGetPageLayout($this, false, "sitemap/index.php");

$objView->assignobj($this);
$objView->display(SITE_FRAME);
}

/**
* デストラクタ.
*
* @return void
*/
function destroy() {
parent::destroy();
}

// カテゴリツリーの取得
function lfGetCatTree($arrParent_category_id, $count_check = false) {
$objQuery = new SC_Query();
$objDb = new SC_Helper_DB_Ex();
$col = "*";
$from = "dtb_category left join dtb_category_total_count using (category_id)";
// 登録商品数のチェック
if($count_check) {
$where = "del_flg = 0 AND product_count > 0";
} else {
$where = "del_flg = 0";
}
$objQuery->setoption("ORDER BY rank DESC");
$arrRet = $objQuery->select($col, $from, $where);

foreach ($arrParent_category_id as $category_id) {
$arrParentID = $objDb->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id);
$arrBrothersID = SC_Utils_Ex::sfGetBrothersArray($arrRet, 'parent_category_id', 'category_id', $arrParentID);
$arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $category_id);

$this->root_parent_id[] = $arrParentID[0];

$arrDispID = array_merge($arrBrothersID, $arrChildrenID);

foreach($arrRet as $key => $array) {
foreach($arrDispID as $val) {
if($array['category_id'] == $val) {
$arrRet[$key]['display'] = 1;
break;
}
}
}
}

$this->arrTree = $arrRet;
}

// メインカテゴリーの取得
function lfGetMainCat($count_check = false, &$objSubPage) {
$objQuery = new SC_Query();
$col = "*";
$from = "dtb_category left join dtb_category_total_count using (category_id)";
// メインカテゴリーとその直下のカテゴリーを取得する。
$where = 'level <= 2 AND del_flg = 0';
// 登録商品数のチェック
if($count_check) {
$where .= " AND product_count > 0";
}
$objQuery->setoption("ORDER BY rank DESC");
$arrRet = $objQuery->select($col, $from, $where);

// メインカテゴリーを抽出する。
$arrMainCat = array();
foreach ($arrRet as $cat) {
if ($cat['level'] != 1) {
continue;
}

// 子カテゴリーを持つかどうかを調べる。
$arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $cat['category_id']);
$cat['has_children'] = count($arrChildrenID) > 0;
$arrMainCat[] = $cat;
}

$objSubPage->arrCat = $arrMainCat;
return $objSubPage;
}
}
?>

4.サイトマップのページ詳細設定の内容
<div id="undercolumn">
<div id="listtitle">
<h2>サイトマップ</h2>
</div>
<div>
<ul>
<li><a href="<!--{$smarty.const.SITE_URL}-->">トップページ</a></li>
<li><a href="<!--{$smarty.const.URL_DIR}-->products/list.php">全商品</a></li>
<!--{assign var=preLev value=1}-->
<!--{assign var=firstdone value=0}-->
<!--{section name=cnt loop=$arrTree}-->
<!--{assign var=level value=`$arrTree[cnt].level`}-->
<!--{assign var=levdiff value=`$level-$preLev`}-->
<!--{if $levdiff > 0}-->
<ul>
<!--{elseif $levdiff == 0 && $firstdone == 1}-->
</li>
<!--{elseif $levdiff < 0}-->
<!--{section name=d loop=`$levdiff*-1`}-->
</li>
</ul>
<!--{/section}-->
</li>
<!--{/if}-->
<li class="level<!--{$level}--><!--{if in_array($arrTree[cnt].category_id, $tpl_category_id) }--> onmark<!--{/if}-->"><a href="<!--{$smarty.const.URL_DIR}-->products/list.php?category_id=<!--{$arrTree[cnt].category_id}-->"<!--{if in_array($arrTree[cnt].category_id, $tpl_category_id) }--> class="onlink"<!--{/if}-->><!--{$arrTree[cnt].category_name|escape}-->(<!--{$arrTree[cnt].product_count|default:0}-->)</a>
<!--{if $firstdone == 0}--><!--{assign var=firstdone value=1}--><!--{/if}-->
<!--{assign var=preLev value=`$level`}-->
<!--{* セクションの最後に閉じタグを追加 *}-->
<!--{if $smarty.section.cnt.last}-->
<!--{if $preLev-1 > 0 }-->
<!--{section name=d loop=`$preLev-1`}-->
</li>
</ul>
<!--{/section}-->
</li>
<!--{else}-->
</li>
<!--{/if}-->
<!--{/if}-->
<!--{/section}-->
<li><a href="<!--{$smarty.const.URL_DIR}-->abouts/index.php">当サイトについて</a></li>
<li><a href="<!--{$smarty.const.SSL_URL}-->contact/index.php">お問い合わせ</a></li>
<li><a href="<!--{$smarty.const.URL_DIR}-->order/index.php">特定商取引に関する法律</a></li>
<li><a href="<!--{$smarty.const.URL_DIR}-->sitemap/index.php">サイトマップ</a></li>
</ul>
</div>
<div>


----------------
Yasuhiro Suzuki
http://www.nishi-shinjuku.net/

tao_s
投稿日時: 2010/1/14 5:11
対応状況: −−−
仙人
登録日: 2008/8/20
居住地: 東京
投稿: 799
Re: サイトマップページの作成
EC-CUBEではinit()の後にprocess()が実行されます。
なので、メインのロジックはprocess()内に書かないとダメですよ。


----------------
EC-CUBEカスタマイズ相談してください。
緊急のEC-CUBEの障害対応
EC-CUBEカスタマイズブログ

Yasuhiro
投稿日時: 2010/1/14 12:20
対応状況: −−−
半人前
登録日: 2010/1/12
居住地: 新宿区
投稿: 22
Re: サイトマップページの作成
引用:

tao_sさんは書きました:
EC-CUBEではinit()の後にprocess()が実行されます。
なので、メインのロジックはprocess()内に書かないとダメですよ。


つまり、全てphp内で処理させる方法ですね?
その場合のLC_Page_Sitemap.phpのソースは、どのようになるのでしょうか?

http://eccube-customize.xross-cube.com/sitemap/index.php
具体的にこちらのケースでは、どのように記述しているか、参考にさせて下さい。


----------------
Yasuhiro Suzuki
http://www.nishi-shinjuku.net/

flealog
投稿日時: 2010/1/14 15:56
対応状況: −−−
仙人
登録日: 2008/6/10
居住地:
投稿: 485
Re: サイトマップページの作成
ぐはっ!?
編集ミスった・・・orz

ソースを参考に少し書き足したら表示されましたよ〜
参考になるようでしたら使ってください^^

LC_Page_Sitemap.php

<?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/LC_Page.php");

/**
* サイトマップ のページクラス.
*
* @package Page
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Entry_Kiyaku.php 16741 2007-11-08 00:43:24Z adachi $
*/
class LC_Page_Sitemap extends LC_Page {

    // {{{ properties

    /** ページナンバー */
    var $tpl_pageno;

    // }}}
    // {{{ functions

    /**
    * Page を初期化する.
    *
    * @return void
    */
    function init() {
        parent::init();
        $this->tpl_mainpage = 'sitemap/index.tpl';
        $this->tpl_title = "サイトマップ";
    }

    /**
    * Page のプロセス.
    *
    * @return void
    */
    function process() {
        $objView = new SC_SiteView();
        $objQuery = new SC_Query();
        $objCustomer = new SC_Customer();
        $objDb = new SC_Helper_DB_Ex();

        // レイアウトデザインを取得
        $objLayout = new SC_Helper_PageLayout_Ex();
        $objLayout->sfGetPageLayout($this, false, "sitemap/index.php");

        $this->lfGetCatTree($this->tpl_category_id, true, $this);

        $objView->assignobj($this);
        $objView->display(SITE_FRAME);
    }

    /**
    * モバイルページを初期化する.
    *
    * @return void
    */
    function mobileInit() {
        $this->init();
    }

    /**
    * Page のプロセス(モバイル).
    *
    * @return void
    */
    function mobileProcess() {
        $objView = new SC_MobileView();
        $objCustomer = new SC_Customer();

        $offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
        $next = $offset;

        // レイアウトデザインを取得
        $objLayout = new SC_Helper_PageLayout_Ex();
        $objLayout->sfGetPageLayout($this, false, "sitemap/index.php");

        $objView->assignobj($this);
        $objView->display(SITE_FRAME);
    }

    /**
    * デストラクタ.
    *
    * @return void
    */
    function destroy() {
        parent::destroy();
    }

    // カテゴリツリーの取得
    function lfGetCatTree($arrParent_category_id, $count_check = false) {
        $objQuery = new SC_Query();
        $objDb = new SC_Helper_DB_Ex();
        $col = "*";
        $from = "dtb_category left join dtb_category_total_count using (category_id)";
        // 登録商品数のチェック
        if($count_check) {
            $where = "del_flg = 0 AND product_count > 0";
        } else {
            $where = "del_flg = 0";
        }
        $objQuery->setoption("ORDER BY rank DESC");
        $arrRet = $objQuery->select($col, $from, $where);

        foreach ($arrParent_category_id as $category_id) {
            $arrParentID = $objDb->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id);
            $arrBrothersID = SC_Utils_Ex::sfGetBrothersArray($arrRet, 'parent_category_id', 'category_id', $arrParentID);
            $arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $category_id);

            $this->root_parent_id[] = $arrParentID[0];

            $arrDispID = array_merge($arrBrothersID, $arrChildrenID);

            foreach($arrRet as $key => $array) {
                foreach($arrDispID as $val) {
                    if($array['category_id'] == $val) {
                        $arrRet[$key]['display'] = 1;
                        break;
                    }
                }
            }
        }

        $this->arrTree = $arrRet;
    }

    // メインカテゴリーの取得
    function lfGetMainCat($count_check = false, &$objSubPage) {
        $objQuery = new SC_Query();
        $col = "*";
        $from = "dtb_category left join dtb_category_total_count using (category_id)";
        // メインカテゴリーとその直下のカテゴリーを取得する。
        $where = 'level <= 2 AND del_flg = 0';
        // 登録商品数のチェック
        if($count_check) {
            $where .= " AND product_count > 0";
        }
        $objQuery->setoption("ORDER BY rank DESC");
        $arrRet = $objQuery->select($col, $from, $where);

        // メインカテゴリーを抽出する。
        $arrMainCat = array();
        foreach ($arrRet as $cat) {
            if ($cat['level'] != 1) {
                continue;
            }

            // 子カテゴリーを持つかどうかを調べる。
            $arrChildrenID = SC_Utils_Ex::sfGetUnderChildrenArray($arrRet, 'parent_category_id', 'category_id', $cat['category_id']);
            $cat['has_children'] = count($arrChildrenID) > 0;
            $arrMainCat[] = $cat;
        }

        $objSubPage->arrCat = $arrMainCat;
        return $objSubPage;
    }
}
?>


----------------
EC-CUBE3っぽいテンプレート
GitHub で公開中
https://github.com/bluestylejp

お問い合わせ番号CSV登録&メール送信プラグイン
http://urx.red/qDT6

« 1 (2) 3 »
スレッド表示 | 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,644名です
総投稿数は109,891件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2311
5
umebius
2085
6
yuh
1819
7
h_tanaka
1635
8
red
1569
9
mcontact
1265
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.