Ecshop-based mobile Etouch for dynamic access to categorized product listings

Source: Internet
Author: User
Modify File category.php

Key two places to modify

if($_get[' act '] ==' Asynclist ') {$sayList= Array ();if(Is_array ($goodslist) {foreach ($goodslistAs$vo) {$shop _price= Empty ($vo[' Promote_price ']) ?$vo[' Shop_price ']:$vo[' Promote_price '];$watermark _img= Empty ($vo[' watermark_img ']) ?'':'.' themes/'.$_cfg[' template '].'/images/'.$vo[' watermark_img '].'. png ' alt= "Ecshop-based mobile Etouch for dynamic access to categorized product listings".$vo[' Goods_name '].'/> '; /*$sayList[] = Array (' Pro-inner '='         .$vo[' URL '].' >. $config [' Site_url ']. $vo [' Goods_thumb ']. ' alt= ' is based on Ecshop's mobile Etouch to achieve dynamic access to categorized product listings. $vo [' Goods_name ']. ' >. $vo [' URL ']. ' >'. $vo [' name ']. ' ' . $shop _price . ' ' . $vo [' Market_price ']. ' monthly pin:'  . $vo [' Sales_count ']. ' '.$watermark _img.'        ');*/$collectStr='';if($vo[' Collect ']) {//If you have already searched the hidden$collectStr=' $vo[' goods_id '].' > '; }Else{//If there are no hidden searches then$collectStr=' $vo[' goods_id '].' > '; }$sayList[] = Array (' Pro-inner '='                     .$vo[' URL ']. ' ">.  $config  [ ' Site_url ' ].  $vo  [ ' Goods_thumb ' ]. The  ' alt= ' is based on Ecshop's mobile Etouch implementation to dynamically get the categorized item list .  $vo  [ ' Goods_name ' ].  ' >  ' .  $vo  [ ' name ' ].  '  

' . $shop _price . '

Month Pin: '. $vo [ ' Sales_count ' ]. '

'. $collectStr . '!--]. ' " & #xe62a; -->  ' ); }} echo json_encode ( $sayList ); exit ; }

And there's a function called Category_get_goods. This function adds a field collect the return field can be used for front-end Page view rendering to determine if it has been searched and to display different style and binding event functions depending on whether the search is hidden or not

/** * Get classified items * * @access public * @param string $children * @return Array */ functioncategory_get_goods($children, $brand, $min, $ Max, $ext, $size, $page, $sort, $order){$display=$GLOBALS[' Display '];$where="G.is_on_sale = 1 and G.is_alone_sale = 1 and"."G.is_delete = 0 and ($children OR". Get_extension_goods ($children) .')';if($brand>0)    {$where.="and g.brand_id= $brand"; }if($min>0)    {$where.="and G.shop_price >= $min"; }if($max>0)    {$where.="and G.shop_price <= $max"; }/ * Get a list of items * /$sql=' SELECT g.goods_id, G.goods_name, G.goods_name_style, G.market_price, G.is_new, G.is_best, G.is_hot, G.shop_price As Org_price, '."Ifnull (Mp.user_price, G.shop_price * ' $_session[discount] ') as Shop_price, G.promote_price, G.goods_type,".' G.promote_start_date, G.promote_end_date, G.goods_brief, G.goods_thumb, g.goods_img '.' from '.$GLOBALS[' ECS ']->table (' goods ') .' as G '.' left JOIN '.$GLOBALS[' ECS ']->table (' Member_price ') .' as MP '."on mp.goods_id = g.goods_id and Mp.user_rank = ' $_session[user_rank] '"."WHERE $where $ext ORDER by $sort $order";$res=$GLOBALS[' DB ']->selectlimit ($sql,$size, ($page-1) *$size);$arr=Array(); while($row=$GLOBALS[' DB ']->fetchrow ($res))    {if($row[' Promote_price '] >0)        {$promote _price= Bargain_price ($row[' Promote_price '],$row[' Promote_start_date '],$row[' Promote_end_date ']); }Else{$promote _price=0; }/ * Handle the product watermark picture * /$watermark _img='';if($promote _price!=0)        {$watermark _img="Watermark_promote_small"; }ElseIf($row[' Is_new '] !=0)        {$watermark _img="Watermark_new_small"; }ElseIf($row[' Is_best '] !=0)        {$watermark _img="Watermark_best_small"; }ElseIf($row[' Is_hot '] !=0)        {$watermark _img=' Watermark_hot_small '; }if($watermark _img!='')        {$arr[$row[' goods_id ']][' watermark_img '] =$watermark _img; }$arr[$row[' goods_id ']][' goods_id ']         =$row[' goods_id '];if($display==' Grid ')        {$arr[$row[' goods_id ']][' Goods_name ']       =$GLOBALS[' _cfg '][' Goods_name_length '] >0? SUB_STR ($row[' Goods_name '],$GLOBALS[' _cfg '][' Goods_name_length ']) :$row[' Goods_name ']; }Else{$arr[$row[' goods_id ']][' Goods_name ']       =$row[' Goods_name ']; }$arr[$row[' goods_id ']][' name ']             =$row[' Goods_name '];$arr[$row[' goods_id ']][' Goods_brief ']      =$row[' Goods_brief '];$arr[$row[' goods_id ']][' Goods_style_name '] = Add_style ($row[' Goods_name '],$row[' Goods_name_style ']);$arr[$row[' goods_id ']][' Market_price '] = Price_format ($row[' Market_price ']);$arr[$row[' goods_id ']][' Shop_price '] = Price_format ($row[' Shop_price ']);$arr[$row[' goods_id ']][' type ']             =$row[' Goods_type '];$arr[$row[' goods_id ']][' Promote_price ']    = ($promote _price>0) ? Price_format ($promote _price) :'';$arr[$row[' goods_id ']][' Goods_thumb '] = Get_image_path ($row[' goods_id '],$row[' Goods_thumb '],true);$arr[$row[' goods_id ']][' goods_img '] = Get_image_path ($row[' goods_id '],$row[' goods_img ']);$arr[$row[' goods_id ']][' URL '] = Build_uri (' goods ',Array(' gid '=$row[' goods_id ']),$row[' Goods_name ']);$arr[$row[' goods_id ']][' Sales_count '] = Get_sales_volume ($row[' goods_id ']);//Show monthly sales by Wangif(isset($_session[' user_id ']) ||$_session[' user_id '] !=0)        {/ * Check if the user's favorites are already present * /$sql="Select COUNT (*) from".$GLOBALS[' ECS ']->table (' Collect_goods ') ."WHERE user_id= ' $_session[user_id] ' and goods_id = '".$row[' goods_id ']."'";if($GLOBALS[' DB ']->getone ($sql) >0)            {$arr[$row[' goods_id ']][' Collect '] =1; }Else{$arr[$row[' goods_id ']][' Collect '] =0; }        }Else{$arr[$row[' goods_id ']][' Collect '] =0; }    }return$arr;}

Client JS Code Reference

/* * * Add items to favourites */var_current_collect =NULL;var_current_goodsid =0; functioncollect(_this,goodsid){_current_collect = _this;  _current_goodsid = Goodsid; Jquery.get (' User.php?act=collect ', {id:goodsid},collectresponse,"JSON");} functionuncollect(_this,goodsid){_current_collect = _this;  _current_goodsid = Goodsid; Jquery.get (' User.php?act=uncollect ', {id:goodsid},collectresponse,"JSON");}/* * * Handling feedback from favorite items * * functioncollectresponse(Result){if(parseint(result.error) = = =0) {_current_collect.classname =''; _current_collect.classname ="Ycd-font-icon uncollect"; _current_collect.setattribute (' onclick ',"Uncollect (This,"+_current_goodsid+")"); _current_collect.innerhtml ='  '; }if(parseint(result.error) = = =3) {_current_collect.classname =''; _current_collect.classname ="Ycd-font-icon collect"; _current_collect.setattribute (' onclick ',"Collect (this,"+_current_goodsid+")"); _current_collect.innerhtml ='  '; }//Join success here//Note here is a plugin that is written on its own, based on the Zepto mobile End Function library, please refer to the code of this plugin in an article I wrote earlier .Zepto (' body '). Popup ({title:' hint message 'Id:' alert ', Closeonok:trueOk:' OK ', message:result.message}); }

Summarize

I used to like PHP for a while, so PHP code is basically able to read MySQL also learned
Children's shoes without PHP Foundation can learn the basics of PHP first
Now bloggers are working on the front-end backend and learning about new APIs for JavaScript and HTML5 recently.
Keep a record of your work

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the mobile Etouch based on Ecshop to achieve dynamic access to classified product list, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.