質問 > その他 > カテゴリ毎に説明文等のコンテンツを表示する |
その他
スレッド表示 | 古いものから | 前のトピック | 次のトピック | 下へ |
投稿者 | スレッド |
---|---|
kinnobitou |
投稿日時: 2010/4/15 14:39
対応状況: −−−
|
常連 登録日: 2010/4/1 居住地: 投稿: 46 |
Re: カテゴリ毎に説明文等のコンテンツを表示する ukaiさん
ほんとうに ほんとうに ありがとうございます!!! できました!!!! めっちゃうれしい!!!! ukaiさんのおかげです!! ほんとうにご丁寧な対応ありがとうございます!! また幾度となく質問すると思いますがよろしくお願いいたします。 |
ukai |
投稿日時: 2010/4/15 13:36
対応状況: −−−
|
常連 登録日: 2009/5/29 居住地: 東京都 投稿: 54 |
Re: カテゴリ毎に説明文等のコンテンツを表示する 引用:
これは内容的には、destroyという関数が二つ存在しますよという エラーだと思います。 先ほどのせていただいたコードに 確かにdestroyが二つ存在するみたいなので、 コピーして貼り付けた方を消してあげるといいと思います。 あと蛇足かもしれませんが、参考ページのほうでは プロセス関数を丸ごとコピーとあったので、コピーするのは この下にコピーした部分(プロセス関数と書いた部分) だけでも大丈夫だと思います プロセス関数 -------------------------------------------------------- /** * Page のプロセス. * * @return void */ function process() { //parent::process(); $objCustomer = new SC_Customer(); $objView = new SC_SiteView(); $conn = new SC_DBConn(); $objDb = new SC_Helper_DB_Ex(); //表示件数の選択 if(isset($_POST['disp_number']) && SC_Utils_Ex::sfIsInt($_POST['disp_number'])) { $this->disp_number = $_POST['disp_number']; } else { //最小表示件数を選択 $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); } //表示順序の保存 $this->orderby = isset($_POST['orderby']) ? $_POST['orderby'] : ""; // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']); if (!isset($_GET['mode'])) $_GET['mode'] = ""; if (!isset($_GET['name'])) $_GET['name'] = ""; if (!isset($_POST['orderby'])) $_POST['orderby'] = ""; if (empty($arrCategory_id)) $arrCategory_id = array("0"); // タイトル編集 $tpl_subtitle = ""; if ($_GET['mode'] == 'search') { $tpl_subtitle = "検索結果"; } elseif (empty($arrCategory_id[0])) { $tpl_subtitle = "全商品"; } else { $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); $tpl_subtitle = $arrFirstCat['name']; } $objQuery = new SC_Query(); $this->category_info = $objQuery->get("dtb_category", "category_info", "category_id = ?", $arrCategory_id); $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id); // 以下の条件でBEST商品を表示する // ・BEST最大数の商品が登録されている。 // ・カテゴリIDがルートIDである。 // ・検索モードでない。 if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) { // 商品TOPの表示処理 $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]); $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); } else { if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){ // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す $arrCategory_id = array(0); } // 商品一覧の表示処理 $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_POST['orderby']); // 検索条件を画面に表示 // カテゴリー検索条件 if (strlen($_GET['category_id']) == 0) { $arrSearch['category'] = "指定なし"; }else{ $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", $arrCategory_id); $arrSearch['category'] = $arrCat; } // 商品名検索条件 if ($_GET['name'] === "") { $arrSearch['name'] = "指定なし"; }else{ $arrSearch['name'] = $_GET['name']; } } // レイアウトデザインを取得 $layout = new SC_Helper_PageLayout_Ex(); $layout->sfGetPageLayout($this, false, "products/list.php"); if(isset($_POST['mode']) && $_POST['mode'] == "cart" && $_POST['product_id'] != "") { // 値の正当性チェック if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); } else { // 入力値の変換 $this->arrErr = $this->lfCheckError($_POST['product_id']); if(count($this->arrErr) == 0) { $objCartSess = new SC_CartSession(); $classcategory_id = "classcategory_id". $_POST['product_id']; $classcategory_id1 = $_POST[$classcategory_id. '_1']; $classcategory_id2 = $_POST[$classcategory_id. '_2']; $quantity = "quantity". $_POST['product_id']; // 規格1が設定されていない場合 if(!$this->tpl_classcat_find1[$_POST['product_id']]) { $classcategory_id1 = '0'; } // 規格2が設定されていない場合 if(!$this->tpl_classcat_find2[$_POST['product_id']]) { $classcategory_id2 = '0'; } $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]); $this->sendRedirect($this->getLocation(URL_CART_TOP)); exit; } } } $this->tpl_subtitle = $tpl_subtitle; // 支払方法の取得 $this->arrPayment = $this->lfGetPayment(); // 入力情報を渡す $this->arrForm = $_POST; $this->lfConvertParam(); $this->category_id = $arrCategory_id[0]; $this->arrSearch = $arrSearch; $objView->assignobj($this); $objView->display(SITE_FRAME); } --------------------------------------------- この下の関数が二つあります。 --------------------------------------------- /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } --------------------------------------------- |
kinnobitou |
投稿日時: 2010/4/15 12:54
対応状況: −−−
|
常連 登録日: 2010/4/1 居住地: 投稿: 46 |
Re: カテゴリ毎に説明文等のコンテンツを表示する ukaiさんありがとうございます。 --------------------------------------------------------- function lfconvertParam () { foreach ($this->arrForm as $key => $value) { if (preg_match('/^quantity[0-9]+/', $key)) { $this->arrForm[$key] = htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE); } --------------------------------------------------------- この部分の(コードの最後のほうです) コピー漏れかもしれませんが、「}」が 最後二つ足りない気がします。 は入れてやってみたんですがエラーがでます。 エラーなんですが、たとえば カテゴリーの【服】を押すと下記のようなエラー内容がでます。 Fatal error: Cannot redeclare LC_Page_Products_List_Ex::destroy() /data/class_extends/page_extends/products/LC_Page_Products_List_Ex.php on line 731 これはどういうエラーでしょうか? わかるようでしたらご回答よろしくお願いいたします。 |
ukai |
投稿日時: 2010/4/15 10:45
対応状況: −−−
|
常連 登録日: 2009/5/29 居住地: 東京都 投稿: 54 |
Re: カテゴリ毎に説明文等のコンテンツを表示する こんにちは。
そうですね…ぱっと見たところだと修正された箇所も そんなにないようなので、うまくいきそうなんですが ちなみにどんなエラーですか? システムエラーなら、また data/logs/site.log にエラー内容がでていると思います。 画面が真っ白になるとかでしたら、コードのスペルミスとか }が一つ多いとかの場合が多いです。 あとはテンプレートのミスとか。 --------------------------------------------------------- function lfconvertParam () { foreach ($this->arrForm as $key => $value) { if (preg_match('/^quantity[0-9]+/', $key)) { $this->arrForm[$key] = htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE); } --------------------------------------------------------- この部分の(コードの最後のほうです) コピー漏れかもしれませんが、「}」が 最後二つ足りない気がします。 |
kinnobitou |
投稿日時: 2010/4/14 19:16
対応状況: −−−
|
常連 登録日: 2010/4/1 居住地: 投稿: 46 |
Re: カテゴリ毎に説明文等のコンテンツを表示する ukaiさんありがとうござます。
データベースの件は、なんとかいけたような気がします。 ukaiさんの言うとおり、info_flgを作り直したらエラーがでなくないりました。 しかしまた新たな問題が.... LC_Page_Products_List_Ex.phpの編集ですが、エラーがでます。 コードに問題があると思うのですが、どこが間違っているんでしょう? /** * Page のプロセス. * * @return void */ function process() { //parent::process(); $objCustomer = new SC_Customer(); $objView = new SC_SiteView(); $conn = new SC_DBConn(); $objDb = new SC_Helper_DB_Ex(); //表示件数の選択 if(isset($_POST['disp_number']) && SC_Utils_Ex::sfIsInt($_POST['disp_number'])) { $this->disp_number = $_POST['disp_number']; } else { //最小表示件数を選択 $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); } //表示順序の保存 $this->orderby = isset($_POST['orderby']) ? $_POST['orderby'] : ""; // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']); if (!isset($_GET['mode'])) $_GET['mode'] = ""; if (!isset($_GET['name'])) $_GET['name'] = ""; if (!isset($_POST['orderby'])) $_POST['orderby'] = ""; if (empty($arrCategory_id)) $arrCategory_id = array("0"); // タイトル編集 $tpl_subtitle = ""; if ($_GET['mode'] == 'search') { $tpl_subtitle = "検索結果"; } elseif (empty($arrCategory_id[0])) { $tpl_subtitle = "全商品"; } else { $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); $tpl_subtitle = $arrFirstCat['name']; } $objQuery = new SC_Query(); $this->category_info = $objQuery->get("dtb_category", "category_info", "category_id = ?", $arrCategory_id); $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id); // 以下の条件でBEST商品を表示する // ・BEST最大数の商品が登録されている。 // ・カテゴリIDがルートIDである。 // ・検索モードでない。 if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) { // 商品TOPの表示処理 $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]); $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); } else { if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){ // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す $arrCategory_id = array(0); } // 商品一覧の表示処理 $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_POST['orderby']); // 検索条件を画面に表示 // カテゴリー検索条件 if (strlen($_GET['category_id']) == 0) { $arrSearch['category'] = "指定なし"; }else{ $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", $arrCategory_id); $arrSearch['category'] = $arrCat; } // 商品名検索条件 if ($_GET['name'] === "") { $arrSearch['name'] = "指定なし"; }else{ $arrSearch['name'] = $_GET['name']; } } // レイアウトデザインを取得 $layout = new SC_Helper_PageLayout_Ex(); $layout->sfGetPageLayout($this, false, "products/list.php"); if(isset($_POST['mode']) && $_POST['mode'] == "cart" && $_POST['product_id'] != "") { // 値の正当性チェック if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); } else { // 入力値の変換 $this->arrErr = $this->lfCheckError($_POST['product_id']); if(count($this->arrErr) == 0) { $objCartSess = new SC_CartSession(); $classcategory_id = "classcategory_id". $_POST['product_id']; $classcategory_id1 = $_POST[$classcategory_id. '_1']; $classcategory_id2 = $_POST[$classcategory_id. '_2']; $quantity = "quantity". $_POST['product_id']; // 規格1が設定されていない場合 if(!$this->tpl_classcat_find1[$_POST['product_id']]) { $classcategory_id1 = '0'; } // 規格2が設定されていない場合 if(!$this->tpl_classcat_find2[$_POST['product_id']]) { $classcategory_id2 = '0'; } $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]); $this->sendRedirect($this->getLocation(URL_CART_TOP)); exit; } } } $this->tpl_subtitle = $tpl_subtitle; // 支払方法の取得 $this->arrPayment = $this->lfGetPayment(); // 入力情報を渡す $this->arrForm = $_POST; $this->lfConvertParam(); $this->category_id = $arrCategory_id[0]; $this->arrSearch = $arrSearch; $objView->assignobj($this); $objView->display(SITE_FRAME); } /** * モバイルページを初期化する. * * @return void */ function mobileInit() { $this->init(); } /** * Page のプロセス(モバイル). * * FIXME スパゲッティ... * * @return void */ function mobileProcess() { $objView = new SC_MobileView(); $conn = new SC_DBConn(); $objDb = new SC_Helper_DB_Ex(); //表示件数の選択 if(isset($_REQUEST['disp_number']) && SC_Utils_Ex::sfIsInt($_REQUEST['disp_number'])) { $this->disp_number = $_REQUEST['disp_number']; } else { //最小表示件数を選択 $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); } //表示順序の保存 $this->orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : ""; // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']); // タイトル編集 $tpl_subtitle = ""; $tpl_search_mode = false; if (!isset($_GET['mode'])) $_GET['mode'] = ""; if (!isset($_POST['mode'])) $_POST['mode'] = ""; if (!isset($_GET['name'])) $_GET['name'] = ""; if (!isset($_REQUEST['orderby'])) $_REQUEST['orderby'] = ""; if (empty($arrCategory_id)) $arrCategory_id = array("0"); if($_GET['mode'] == 'search'){ $tpl_subtitle = "検索結果"; $tpl_search_mode = true; }elseif (empty($arrCategory_id[0])) { $tpl_subtitle = "全商品"; }else{ $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); $tpl_subtitle = $arrFirstCat['name']; } $objQuery = new SC_Query(); $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id); // 以下の条件でBEST商品を表示する // ・BEST最大数の商品が登録されている。 // ・カテゴリIDがルートIDである。 // ・検索モードでない。 if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) { // 商品TOPの表示処理 $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]); $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); } else { if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){ // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す $arrCategory_id = array(""); } // 商品一覧の表示処理 $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_REQUEST['orderby']); // 検索条件を画面に表示 // カテゴリー検索条件 if (strlen($_GET['category_id']) == 0) { $arrSearch['category'] = "指定なし"; }else{ $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($category_id)); $arrSearch['category'] = $arrCat; } // 商品名検索条件 if ($_GET['name'] === "") { $arrSearch['name'] = "指定なし"; }else{ $arrSearch['name'] = $_GET['name']; } } if($_POST['mode'] == "cart" && $_POST['product_id'] != "") { // 値の正当性チェック if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !SC_Utils_Ex::sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true); } else { // 入力値の変換 $this->arrErr = $this->lfCheckError($_POST['product_id']); if(count($this->arrErr) == 0) { $objCartSess = new SC_CartSession(); $classcategory_id = "classcategory_id". $_POST['product_id']; $classcategory_id1 = $_POST[$classcategory_id. '_1']; $classcategory_id2 = $_POST[$classcategory_id. '_2']; $quantity = "quantity". $_POST['product_id']; // 規格1が設定されていない場合 if(!$this->tpl_classcat_find1[$_POST['product_id']]) { $classcategory_id1 = '0'; } // 規格2が設定されていない場合 if(!$this->tpl_classcat_find2[$_POST['product_id']]) { $classcategory_id2 = '0'; } $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]); $this->sendRedirect(MOBILE_URL_CART_TOP, array(session_name() => session_id())); exit; } } } // ページ送り機能用のURLを作成する。 $objURL = new Net_URL($_SERVER['PHP_SELF']); foreach ($_REQUEST as $key => $value) { if ($key == session_name() || $key == 'pageno') { continue; } $objURL->addQueryString($key, mb_convert_encoding($value, 'SJIS', CHAR_CODE)); } if ($this->objNavi->now_page > 1) { $objURL->addQueryString('pageno', $this->objNavi->now_page - 1); $this->tpl_previous_page = $objURL->path . '?' . $objURL->getQueryString(); } if ($this->objNavi->now_page < $this->objNavi->max_page) { $objURL->addQueryString('pageno', $this->objNavi->now_page + 1); $this->tpl_next_page = $objURL->path . '?' . $objURL->getQueryString(); } $this->tpl_subtitle = $tpl_subtitle; $this->tpl_search_mode = $tpl_search_mode; // 支払方法の取得 $this->arrPayment = $this->lfGetPayment(); // 入力情報を渡す $this->arrForm = $_POST; $this->category_id = $arrCategory_id[0]; $this->arrSearch = $arrSearch; $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "products/list.tpl"; $objView->assignobj($this); $objView->display(SITE_FRAME); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } /* カテゴリIDがルートかどうかの判定 */ function lfIsRootCategory($category_id) { $objQuery = new SC_Query(); $level = $objQuery->get("dtb_category", "level", "category_id = ?", array($category_id)); if($level == 1) { return true; } return false; } /* 商品一覧の表示 */ function lfDispProductsList($category_id, $name, $disp_num, $orderby) { $objQuery = new SC_Query(); $objDb = new SC_Helper_DB_Ex(); $this->tpl_pageno = defined("MOBILE_SITE") ? @$_GET['pageno'] : @$_POST['pageno']; $arrval = array(); $arrval_order = array(); $arrval_category = array(); // カテゴリからのWHERE文字列取得 if ( $category_id ) { list($tmp_where, $arrval_category) = $objDb->sfGetCatWhere($category_id); if (strlen($tmp_where) >= 1) { $where_category = "AND $tmp_where"; //並び替え用(MySQL4.1対応) $where_category_order = "AND " ."T2.".trim($tmp_where); } } // ▼対象商品IDの抽出 // 商品検索条件の作成(未削除、表示) $where = "del_flg = 0 AND status = 1 "; // 在庫無し商品の非表示 if (NOSTOCK_HIDDEN === true) { $where .= ' AND (stock_max >= 1 OR stock_unlimited_max = 1)'; } if (strlen($where_category) >= 1) { $where.= " $where_category"; $arrval = array_merge($arrval, $arrval_category); } // 商品名をwhere文に $name = ereg_replace(",", "", $name);// XXX // 全角スペースを半角スペースに変換 $name = str_replace(' ', ' ', $name); // スペースでキーワードを分割 $names = preg_split("/ +/", $name); // 分割したキーワードを一つずつwhere文に追加 foreach ($names as $val) { if ( strlen($val) > 0 ){ $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) "; $ret = SC_Utils_Ex::sfManualEscape($val); $arrval[] = "%$ret%"; $arrval[] = "%$ret%"; } } $arrProduct_id = $objQuery->getCol('vw_products_allclass AS allcls', 'DISTINCT product_id', $where, $arrval); // ▲対象商品IDの抽出 // 行数の取得 $linemax = count($arrProduct_id); $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 // ページ送りの取得 $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX); $strnavi = $this->objNavi->strnavi; $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi); // 表示文字列 $this->tpl_strnavi = empty($strnavi) ? " " : $strnavi; $startno = $this->objNavi->start_row; // 開始行 // ▼商品詳細取得 $col = <<< __EOS__ product_id ,product_code_min ,product_code_max ,name ,comment1 ,comment2 ,comment3 ,main_list_comment ,main_image ,main_list_image ,price01_min ,price01_max ,price02_min ,price02_max ,stock_min ,stock_max ,stock_unlimited_min ,stock_unlimited_max ,point_rate ,sale_limit ,sale_unlimited ,deliv_date_id ,deliv_fee ,status ,product_flag ,del_flg __EOS__; $from = "vw_products_allclass_detail AS alldtl"; // WHERE 句 $where = '0=0'; if (is_array($arrProduct_id) && !empty($arrProduct_id)) { $where .= ' AND product_id IN (' . implode(',', $arrProduct_id) . ')'; } else { // 一致させない $where .= ' AND 0<>0'; } //表示順序 switch($orderby) { //販売価格順 case 'price': $order = "price02_min, product_id"; break; //新着順 case 'date': $order = "create_date DESC, product_id"; break; default: $order = <<< __EOS__ ( SELECT T3.rank FROM dtb_product_categories T2 JOIN dtb_category T3 USING (category_id) WHERE T2.product_id = alldtl.product_id $where_category_order ORDER BY T3.rank DESC, T2.rank DESC LIMIT 1 ) DESC ,( SELECT T2.rank FROM dtb_product_categories T2 JOIN dtb_category T3 USING (category_id) WHERE T2.product_id = alldtl.product_id $where_category_order ORDER BY T3.rank DESC, T2.rank DESC LIMIT 1 ) DESC ,product_id __EOS__; $arrval_order = array_merge($arrval_category, $arrval_category); break; } // 取得範囲の指定(開始行番号、行数のセット) $objQuery->setlimitoffset($disp_num, $startno); // 表示順序 $objQuery->setorder($order); // 検索結果の取得 $this->arrProducts = $objQuery->select($col, $from, $where, $arrval_order); // ▲商品詳細取得 // 規格名一覧 $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name"); // 規格分類名一覧 $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); // 規格セレクトボックス設定 if($disp_num == 15) { for($i = 0; $i < count($this->arrProducts); $i++) { $this->lfMakeSelect($this->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName); } } } /* 規格セレクトボックスの作成 */ function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) { $classcat_find1 = false; $classcat_find2 = false; // 在庫ありの商品の有無 $stock_find = false; // 商品規格情報の取得 $arrProductsClass = $this->lfGetProductsClass($product_id); // 規格1クラス名の取得 $this->tpl_class_name1[$product_id] = isset($arrClassName[$arrProductsClass[0]['class_id1']]) ? $arrClassName[$arrProductsClass[0]['class_id1']] : ""; // 規格2クラス名の取得 $this->tpl_class_name2[$product_id] = isset($arrClassName[$arrProductsClass[0]['class_id2']]) ? $arrClassName[$arrProductsClass[0]['class_id2']] : ""; // すべての組み合わせ数 $count = count($arrProductsClass); $classcat_id1 = ""; $arrSele = array(); $arrList = array(); $list_id = 0; $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'"; $arrVal[0] = "\tval". $product_id. "_0 = new Array(''"; for ($i = 0; $i < $count; $i++) { // 在庫のチェック if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { continue; } $stock_find = true; // 規格1のセレクトボックス用 if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ $arrList[$list_id].=");\n"; $arrVal[$list_id].=");\n"; $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1]; $list_id++; $arrList[$list_id] = ""; $arrVal[$list_id] = ""; } // 規格2のセレクトボックス用 $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; // セレクトボックス表示値 if($arrList[$list_id] == "") { $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'"; } else { $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'"; } // セレクトボックスPOST値 if($arrVal[$list_id] == "") { $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'"; } else { $arrVal[$list_id].= ", '".$classcat_id2."'"; } } $arrList[$list_id].=");\n"; $arrVal[$list_id].=");\n"; // 規格1 $this->arrClassCat1[$product_id] = $arrSele; $lists = "\tlists".$product_id. " = new Array("; $no = 0; foreach($arrList as $val) { $this->tpl_javascript.= $val; if ($no != 0) { $lists.= ",list". $product_id. "_". $no; } else { $lists.= "list". $product_id. "_". $no; } $no++; } $this->tpl_javascript.= $lists.");\n"; $vals = "\tvals".$product_id. " = new Array("; $no = 0; foreach($arrVal as $val) { $this->tpl_javascript.= $val; if ($no != 0) { $vals.= ",val". $product_id. "_". $no; } else { $vals.= "val". $product_id. "_". $no; } $no++; } $this->tpl_javascript.= $vals.");\n"; // 選択されている規格2ID $classcategory_id = "classcategory_id". $product_id; $classcategory_id_2 = $classcategory_id . "_2"; if (!isset($classcategory_id_2)) $classcategory_id_2 = ""; if (!isset($_POST[$classcategory_id_2]) || !is_numeric($_POST[$classcategory_id_2])) $_POST[$classcategory_id_2] = ""; $this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', " . "'" . $classcategory_id_2 . "'," . "'" . $product_id . "'," . "'" . $_POST[$classcategory_id_2] ."'); "; // 規格1が設定されている if($arrProductsClass[0]['classcategory_id1'] != '0') { $classcat_find1 = true; } // 規格2が設定されている if($arrProductsClass[0]['classcategory_id2'] != '0') { $classcat_find2 = true; } $this->tpl_classcat_find1[$product_id] = $classcat_find1; $this->tpl_classcat_find2[$product_id] = $classcat_find2; $this->tpl_stock_find[$product_id] = $stock_find; } /* 商品規格情報の取得 */ function lfGetProductsClass($product_id) { $arrRet = array(); if(SC_Utils_Ex::sfIsInt($product_id)) { // 商品規格取得 $objQuery = new SC_Query(); $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited"; $table = "vw_product_class AS prdcls"; $where = "product_id = ?"; $objQuery->setorder("rank1 DESC, rank2 DESC"); $arrRet = $objQuery->select($col, $table, $where, array($product_id)); } return $arrRet; } /* 入力内容のチェック */ function lfCheckError($id) { // 入力データを渡す。 $objErr = new SC_CheckError(); $classcategory_id1 = "classcategory_id". $id. "_1"; $classcategory_id2 = "classcategory_id". $id. "_2"; $quantity = "quantity". $id; // 複数項目チェック if ($this->tpl_classcat_find1[$id]) { $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); } if ($this->tpl_classcat_find2[$id]) { $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); } $objErr->doFunc(array("個数", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); return $objErr->arrErr; } //支払方法の取得 //payment_id 1:代金引換 2:銀行振り込み 3:現金書留 function lfGetPayment() { $objQuery = new SC_Query; $col = "payment_id, rule, payment_method"; $from = "dtb_payment"; $where = "del_flg = 0"; $order = "payment_id"; $objQuery->setorder($order); $arrRet = $objQuery->select($col, $from, $where); return $arrRet; } function lfconvertParam () { foreach ($this->arrForm as $key => $value) { if (preg_match('/^quantity[0-9]+/', $key)) { $this->arrForm[$key] = htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } } よろしくお願い致します。 |
ukai |
投稿日時: 2010/4/14 15:35
対応状況: −−−
|
常連 登録日: 2009/5/29 居住地: 東京都 投稿: 54 |
Re: カテゴリ毎に説明文等のコンテンツを表示する 当方の方でも試してみましたが、
同じコードでできてしまいました・・・; 編集を押すと、ということなので やはりprocessの case 'pre_edit': // 編集項目のカテゴリ名をDBより取得する。 //$oquery = new SC_Query(); $objQuery = new SC_Query(); $where = "category_id = ?"; //$cat_name = $oquery->get("dtb_category", "category_name", $where, array($_POST['category_id'])); $col = "category_name, category_info, info_flg, level"; $arrRet = $objQuery->select($col, "dtb_category", $where, array($_POST['category_id'])); // 入力項目にカテゴリ名を入力する。 //$this->arrForm['category_name'] = $cat_name; $this->arrForm['category_name'] = $arrRet[0]['category_name']; $this->arrForm['category_info'] = $arrRet[0]['category_info']; $this->arrForm['info_flg'] = $arrRet[0]['info_flg']; $this->arrForm['level'] = $arrRet[0]['level']; この部分で何かあるんだと思います。 それと今試しにデータベースのinfo_flgのフィールド名を 全角になおしてみたり、あと全角入力→変換したところ kinnobitouさんと同じエラーが出ました。 なので直接の原因がしっかりわからず申し訳ないのですが、 一度データベースの「info_flg」だけ作成し直して見るのも いいかもしれません。 |
ukai |
投稿日時: 2010/4/14 14:57
対応状況: −−−
|
常連 登録日: 2009/5/29 居住地: 東京都 投稿: 54 |
Re: カテゴリ毎に説明文等のコンテンツを表示する こんにちは。
ありがとうございます。 ちなみになんですが、こちら開示していただいたコードは こちらの参照ページ(http://www.eccube-school.jp/products/detail43.html#) の上の関数から順に 書いていただいていると考えてOKですか? それと確か2ページ目にテンプレートの方の 修正も記載されていましたが、こちらは修正済みですか? |
kinnobitou |
投稿日時: 2010/4/14 14:17
対応状況: −−−
|
常連 登録日: 2010/4/1 居住地: 投稿: 46 |
Re: カテゴリ毎に説明文等のコンテンツを表示する ukaiさんありがとうございます。
----------------------------------------------------- もしよろしかったら、変更・修正して加えたコード部分を 開示していただくことってできますか? ----------------------------------------------------- いかがでしょうか? よろしくお願いいたします。 一応ECCUBE学校のページを参考にしています。 /** * Page のプロセス. * * @return void */ function process() { //parent::process(); $conn = new SC_DBConn(); $objView = new SC_AdminView(); $objSess = new SC_Session(); $objDb = new SC_Helper_DB_Ex(); // 認証可否の判定 SC_Utils_Ex::sfIsSuccess($objSess); // パラメータ管理クラス $this->objFormParam = new SC_FormParam(); // パラメータ情報の初期化 $this->lfInitParam(); // POST値の取得 $this->objFormParam->setParam($_POST); // 通常時は親カテゴリを0に設定する。 $this->arrForm['parent_category_id'] = isset($_POST['parent_category_id']) ? $_POST['parent_category_id'] : ""; if (!isset($_POST['mode'])) $_POST['mode'] = ""; switch($_POST['mode']) { case 'edit': $this->objFormParam->convParam(); $arrRet = $this->objFormParam->getHashArray(); $this->arrErr = $this->lfCheckError($arrRet); if(count($this->arrErr) == 0) { if($_POST['category_id'] == "") { $objQuery = new SC_Query(); $count = $objQuery->count("dtb_category"); if($count < CATEGORY_MAX) { $this->lfInsertCat($_POST['parent_category_id']); } else { print("カテゴリの登録最大数を超えました。"); } } else { $this->lfUpdateCat($_POST['category_id']); } } else { $this->arrForm = array_merge($this->arrForm, $this->objFormParam->getHashArray()); $this->arrForm['category_id'] = $_POST['category_id']; } break; case 'pre_edit': // 編集項目のカテゴリ名をDBより取得する。 //$oquery = new SC_Query(); $objQuery = new SC_Query(); $where = "category_id = ?"; //$cat_name = $oquery->get("dtb_category", "category_name", $where, array($_POST['category_id'])); $col = "category_name, category_info, info_flg, level"; $arrRet = $objQuery->select($col, "dtb_category", $where, array($_POST['category_id'])); // 入力項目にカテゴリ名を入力する。 //$this->arrForm['category_name'] = $cat_name; $this->arrForm['category_name'] = $arrRet[0]['category_name']; $this->arrForm['category_info'] = $arrRet[0]['category_info']; $this->arrForm['info_flg'] = $arrRet[0]['info_flg']; $this->arrForm['level'] = $arrRet[0]['level']; // POSTデータを引き継ぐ $this->arrForm['category_id'] = $_POST['category_id']; break; case 'delete': $objQuery = new SC_Query(); // 子カテゴリのチェック $where = "parent_category_id = ? AND del_flg = 0"; $count = $objQuery->count("dtb_category", $where, array($_POST['category_id'])); if($count != 0) { $this->arrErr['category_name'] = "※ 子カテゴリが存在するため削除できません。<br>"; } // 登録商品のチェック $table = "dtb_product_categories AS T1 LEFT JOIN dtb_products AS T2 ON T1.product_id = T2.product_id"; $where = "T1.category_id = ? AND T2.del_flg = 0"; $count = $objQuery->count($table, $where, array($_POST['category_id'])); if($count != 0) { $this->arrErr['category_name'] = "※ カテゴリ内に商品が存在するため削除できません。<br>"; } if(!isset($this->arrErr['category_name'])) { // ランク付きレコードの削除(※処理負荷を考慮してレコードごと削除する。) $objDb->sfDeleteRankRecord("dtb_category", "category_id", $_POST['category_id'], "", true); } break; case 'up': $objQuery = new SC_Query(); $objQuery->begin(); $up_id = $this->lfGetUpRankID($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); if($up_id != "") { // 上のグループのrankから減算する数 $my_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); // 自分のグループのrankに加算する数 $up_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $up_id); if($my_count > 0 && $up_count > 0) { // 自分のグループに加算 $this->lfUpRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id'], $up_count); // 上のグループから減算 $this->lfDownRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $up_id, $my_count); } } $objQuery->commit(); break; case 'down': $objQuery = new SC_Query(); $objQuery->begin(); $down_id = $this->lfGetDownRankID($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); if($down_id != "") { // 下のグループのrankに加算する数 $my_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); // 自分のグループのrankから減算する数 $down_count = $this->lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $down_id); if($my_count > 0 && $down_count > 0) { // 自分のグループから減算 $this->lfUpRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $down_id, $my_count); // 下のグループに加算 $this->lfDownRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id'], $down_count); } } $objQuery->commit(); break; case 'tree': break; case 'csv': require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php"); $objCSV = new SC_Helper_CSV_Ex(); // CSVを送信する。正常終了の場合、終了。 $objCSV->sfDownloadCategoryCsv() && exit; break; default: $this->arrForm['parent_category_id'] = 0; break; } $this->arrList = $this->lfGetCat($this->arrForm['parent_category_id']); $this->arrTree = $objDb->sfGetCatTree($this->arrForm['parent_category_id']); $objView->assignobj($this); $objView->display(MAIN_FRAME); } // カテゴリの新規追加 function lfInsertCat($parent_category_id) { $objQuery = new SC_Query(); $objQuery->begin(); // トランザクションの開始 if($parent_category_id == 0) { // ROOT階層で最大のランクを取得する。 $where = "parent_category_id = ?"; $rank = $objQuery->max("dtb_category", "rank", $where, array($parent_category_id)) + 1; } else { // 親のランクを自分のランクとする。 $where = "category_id = ?"; $rank = $objQuery->get("dtb_category", "rank", $where, array($parent_category_id)); // 追加レコードのランク以上のレコードを一つあげる。 $sqlup = "UPDATE dtb_category SET rank = (rank + 1) WHERE rank >= ?"; $objQuery->exec($sqlup, array($rank)); } $where = "category_id = ?"; // 自分のレベルを取得する(親のレベル + 1) $level = $objQuery->get("dtb_category", "level", $where, array($parent_category_id)) + 1; // 入力データを渡す。 $sqlval = $this->objFormParam->getHashArray(); $sqlval['create_date'] = "Now()"; $sqlval['update_date'] = "Now()"; $sqlval['creator_id'] = $_SESSION['member_id']; $sqlval['parent_category_id'] = $parent_category_id; $sqlval['rank'] = $rank; $sqlval['level'] = $level; //追記:親の設定を引き継ぐ時 if($sqlval['info_flg']) { $sqlval['category_info'] = $this->lfGetParentInfo($objQuery, $parent_category_id); } // INSERTの実行 $objQuery->insert("dtb_category", $sqlval); $objQuery->commit(); // トランザクションの終了 } // カテゴリの編集 function lfUpdateCat($category_id) { $objQuery = new SC_Query(); // 入力データを渡す。 $sqlval = $this->objFormParam->getHashArray(); $sqlval['update_date'] = "Now()"; $where = "category_id = ?"; //追記:親の設定を引き継ぐ時 if($sqlval['info_flg']) { $parent_category_id = $objQuery->get("dtb_category", "parent_category_id", $where, array($category_id)); $sqlval['category_info'] = $this->lfGetParentInfo($objQuery, $parent_category_id); } $objQuery->update("dtb_category", $sqlval, $where, array($category_id)); } /* パラメータ情報の初期化 */ function lfInitParam() { $this->objFormParam->addParam("カテゴリ名", "category_name", STEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK")); $this->objFormParam->addParam("カテゴリ説明", "category_info", LLTEXT_LEN, "KVa", array("SPTAB_CHECK","MAX_LENGTH_CHECK")); $this->objFormParam->addParam("親カテゴリ説明のコピー", "info_flg", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); } // 追記:親のcategory_infoを取得する function lfGetParentInfo($objQuery, $pid) { $where = "category_id = ?"; $parent_info = $objQuery->get("dtb_category", "category_info", $where, array($pid)); return $parent_info; } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } } ?> 今再度試してみたんですが、やはり同じエラーがでました。 う〜ん 厳しい |
seasoft |
投稿日時: 2010/4/14 9:25
対応状況: −−−
|
神 登録日: 2008/6/4 居住地: 投稿: 7367 |
Re: カテゴリ毎に説明文等のコンテンツを表示する 斜め読みです。参照先へ会員登録していないので、詳細も把握していません。なので、外している確率大ですが・・・
ビューを経由した呼び出しで、ビューへの追加が抜けているとか?
|
ukai |
投稿日時: 2010/4/13 15:34
対応状況: −−−
|
常連 登録日: 2009/5/29 居住地: 東京都 投稿: 54 |
Re: カテゴリ毎に説明文等のコンテンツを表示する うーん…見させていただきましたがスペル等間違っていない
ですね。 SQL文も正しいようですし。 もしよろしかったら、変更・修正して加えたコード部分を 開示していただくことってできますか? あと自分としては、パラメータ情報の初期化あたりの 関数箇所が気になるところです。 それと関係ないと思いますが、info_flgの方にデフォルト値が設定してあるのは必要なんでしょうか?というところです。 |
(1) 2 » |
スレッド表示 | 古いものから | 前のトピック | 次のトピック | トップ |