I use a multi-user mall system, now want to put the store first class category below the two class cycle out, while the two class under the big class automatically read the current two class of recommended stores, how to write. Such as:
The code is as follows:
$v) {$i + +; ?>
F
$store) {?>
- ' Show_store ', ' id ' = = $store [' store_id ']), ' Store ', $store [' Store_domain ']);? > "title=" "target=" _blank "> " onload= "Javascript:drawimage (this,240,240);"/>
Other than that Why not start from 1?
Reply to discussion (solution)
Is your code not implemented? Post $output Content
$i + +; Unconditional execution in foreach ($output [' class_list '] as $k = + $v) {loop
echo $i; In if ($_get[' cate_id ') = = $v [' sc_parent_id ']) {conditional execution in branch
Because the condition may not be true, echo $i; it may not be continuous
Since $i represents a cis, you should delete the $i + + of 9 rows;
and 14 lines of ECHO $i; Change to echo + + $i;
$V) {
$i + +;
?>
Unless there's only one loop here, you initialize $i=0, why do you start with 1?
Is your code not implemented? Post $output Content
$i + +; Unconditional execution in foreach ($output [' class_list '] as $k = + $v) {loop
echo $i; In if ($_get[' cate_id ') = = $v [' sc_parent_id ']) {conditional execution in branch
Because the condition may not be true, echo $i; it may not be continuous
Since $i represents a cis, you should delete the $i + + of 9 rows;
and 14 lines of ECHO $i; Change to echo + + $i;
Class Shop_listcontrol extends Basehomecontrol {/** * store list */public function Indexop () {/** * Read language pack */language::read (' Home_ Store_class_index '); $lang = Language::getlangcontent ();//Shop category Quick Search $class_list = ($h = F (' Store_class '))? $h: H (' Store_class ', true, ' file '), if (!key_exists ($_get[' cate_id '), $class _list)) $_get[' cate_id '] = 0; Tpl::output (' class_list ', $class _list);//Shop Search $model = Model (); $condition = Array (); $keyword = Trim ($_get[' keyword ']); if (C (' Fullindexer.open ') &&!empty ($keyword)) {//full-Text Search $condition = $this->full_search ($keyword);} Else{if ($keyword! = ") {$condition [' store_name|store_zy '] = array (' Like ', '% '. $keyword. ' %');} if ($_get[' user_name '! = ') {$condition [' member_name '] = Trim ($_get[' user_name ']);}} if (!empty ($_get[' area_id ')) {$condition [' area_id '] = Array (' In ', $this->getareanextid (intval ($_get[' area_id ')) ));} if ($_get[' cate_id ' > 0) {$child = Array_merge ((array) $class _list[$_get[' cate_id ']][' child '],array ($_get[' Cate_ ID ']), $condition [' sc_id '] = Array (' In ', $Child);} $condition [' store_state '] = 1;if (!in_array ($_get[' order '],array (' desc ', ' ASC '))} {unset ($_get[' order ']);} if (!in_array ($_get[' key '],array (' store_sales ', ' Store_credit ')) {unset ($_get[' key '));} if (Is_null ($_get[' key ')) {$order = ' store_sort asc ';} else{$order = $_get[' key ']. ' '. $_get[' order ';} if (Isset ($condition [' store.store_id '])) {$condition [' store_id '] = $condition [' store.store_id '];unset ($conditio n[' store.store_id '); } $model _store = Model (' store ');//$store _list = $model _store->where ($condition)->order ($order)->pa GE (->select) (); 20140408 bak $store _list = $model _store->where (' store_recommend=1 ')->order ($order)->page ()->select () ; Get information $store _list = $model _store->getstoresearchlist ($store _list) for the number of stores and the list of recommended items. Tpl::output (' store_list ', $store _list); Tpl::output (' Show_page ', $model->showpage (2));//Current position if (Intval ($_get[' cate_id ']) > 0) {$nav _link[1][' link '] = ' Index.php?act=shop_list '; $nav_link[1][' title ' = $lang [' Site_search_store ']; $nav = $class _list[$_get[' cate_id ']];//if there is a parent if ($nav [' Sc_parent_ Id '] > 0) {$tmp = $class _list[$nav [' sc_parent_id ']];//to parent $nav_link[] = Array (' title ' = = $tmp [' sc_name '], ' link ' = > "index.php?act=shop_list&cate_id=". $nav [' sc_parent_id ']);} Deposit current level $nav_link[] = array (' title ' = = $nav [' sc_name ']);} else{$nav _link[1][' link ' = ' index.php '; $nav _link[1][' title '] = $lang [' homepage ']; $nav _link[2][' title '] = $lang [' Site_search_store '];} Tpl::output (' nav_link_list ', $nav _link);//seomodel (' seo ')->type (' index ')->show (); Tpl::output (' Html_title ', (Empty ($_get[' keyword '))? ": $_get[' keyword ')." C (' site_name '). $lang [' Nc_common_search ']); Tpl::showpage (' shop_list ');}
Is your code not implemented? Post $output Content
$i + +; Unconditional execution in foreach ($output [' class_list '] as $k = + $v) {loop
echo $i; In if ($_get[' cate_id ') = = $v [' sc_parent_id ']) {conditional execution in branch
Because the condition may not be true, echo $i; it may not be continuous
Since $i represents a cis, you should delete the $i + + of 9 rows;
and 14 lines of ECHO $i; Change to echo + + $i;
$i's normal, thanks a lot. Please help to see how to implement the recommended stores below the read subcategories. I am a novice, but also look Haihan
Is your code not implemented? Post $output Content
$i + +; Unconditional execution in foreach ($output [' class_list '] as $k = + $v) {loop
echo $i; In if ($_get[' cate_id ') = = $v [' sc_parent_id ']) {conditional execution in branch
Because the condition may not be true, echo $i; it may not be continuous
Since $i represents a cis, you should delete the $i + + of 9 rows;
and 14 lines of ECHO $i; Change to echo + + $i;
I have now modified the contents of the $store)
$condition [' store_state '] = 1;
$condition [' store_recommend '] = 1;
$condition [' sc_id '] = 66;
$store _list = $model _store->where ($condition)->order ($order)->page ()->select ();
You can now read Sc_id=66 's store, but how do I get the current classification ID and filter it? seemingly able to get to the current classification of the sc_id
You should post $output content (at least a full section) and explain where to put it
You should post $output content (at least a full section) and explain where to put it
The following code is the template file, how to pass the $k value in the first loop to the $where in the second loop. = "$sc _id = $k"; Red part of the piece.
3 Floor, I posted a php processing file.
$i = 0;
?>
$V) {
?>
?>
F ' shop_search ', ' cate_id ' = $k));? > "style=" float:right "target=" _blank "> More ...
$store) {
$where. = "$sc _id = $k";
?>
- ' Show_store ', ' id ' = = $store [' store_id ']), ' Store ', $store [' Store_domain ']);? > "title=" "target=" _blank ">
"Onload=" Javascript:drawimage (this,240,240);/>
To see your data!
What is the use of light to see the code? What if the code is wrong?
after verifying that the above method is not possible,
The code for the template file is:
$v) {?>
F
' shop_search ', ' cate_id ' = $k));? > "style=" float:right "target=" _blank "> More ...
$store) {?>
- ' Show_store ', ' id ' = = $store [' store_id ']), ' Store ', $store [' Store_domain ']);? > "title=" "target=" _blank "> " onload= "Javascript:drawimage (this,240,240);"/>
The code for the store search PHP is
Store Search $model = Model (), $condition = Array (), $keyword = Trim ($_get[' keyword '), if (C (' Fullindexer.open ') &&! Empty ($keyword)) {//full-Text Search $condition = $this->full_search ($keyword);} Else{if ($keyword! = ") {$condition [' store_name|store_zy '] = array (' Like ', '% '. $keyword. ' %');} if ($_get[' user_name '! = ') {$condition [' member_name '] = Trim ($_get[' user_name ']);}} if (!empty ($_get[' area_id ')) {$condition [' area_id '] = Array (' In ', $this->getareanextid (intval ($_get[' area_id ')) ));} if ($_get[' cate_id ' > 0) {$child = Array_merge ((array) $class _list[$_get[' cate_id ']][' child '],array ($_get[' Cate_ ID ']), $condition [' sc_id '] = Array (' in ', $child);} $storeid =array ($Sid); $condition [' store_state '] = 1; $condition [' store_recommend '] = 1;if (!in_array ($_get[' order '), Array (' desc ', ' ASC ')) {unset ($_get[' order '));} if (!in_array ($_get[' key '],array (' store_sales ', ' Store_credit ')) {unset ($_get[' key '));} if (Is_null ($_get[' key ')) {$order = ' store_sort asc ';} else{$order = $_get[' key ']. ' '. $_get[' order ';} if (Isset ($condition [' store.store_id '])) {$condition [' store_id '] = $condition [' store.store_id '];unset ($condi tion[' store.store_id '); } $model _store = Model (' store ');//$store _list = $model _store->where ($condition)->order ($order)->pa GE (->select) (); 20140408 bak $store _list = $model _store->where ($condition)->order ($order)->page ()->select (); Get information $store _list = $model _store->getstoresearchlist ($store _list) for the number of stores and the list of recommended items. Tpl::output (' store_list ', $store _list); Tpl::output (' Show_page ', $model->showpage (2));
Please help to see how to loop out the recommended store under the current classification, the key now is to pass the first foreach in the template $k to the second foreach filter. The key code for filtering is
$condition [' store_state '] = 1;
$condition [' store_recommend '] = 1;
The query is to be performed as per the requirements shown.
You can just print out the final data from the query to see if it meets the requirements of the display.
Two times development, you can call the function of the System column ah, do not write their own
Solve their own, with a very stupid way to judge with if!! The code is as follows: Red section
$i = 0;
?>
$V) {
?>
$Sid = $k;
?>
F ' shop_search ', ' cate_id ' = $k));? > "style=" float:right "target=" _blank "> More ...
$store) {?>
- ' Show_store ', ' id ' = = $store [' store_id ']), ' Store ', $store [' Store_domain ']);? > "title=" "target=" _blank ">
"Onload=" Javascript:drawimage (this,240,240);/>