Ecshop-based mobile terminal etouch enables dynamic acquisition of the list of classified products

Source: Internet
Author: User
Tags learn php basics php basics
: This article mainly introduces how to dynamically retrieve the list of classified products by using the mobile etouch based on ecshop. For more information about PHP tutorials, see. Modify the category. php file

Two key points need to be modified

If ($ _ GET ['act '] = 'asynclist') {$ sayList = array (); if (is_array ($ goodslist )) {foreach ($ goodslist as $ vo) {$ shop_price = empty ($ vo ['promote _ price'])? $ Vo ['shop _ price']: $ vo ['promote _ price']; $ watermark_img = empty ($ vo ['watermark _ img '])? '':'. 'Themes /'. $ _ CFG ['template']. '/images/'.w.vow.'watermark_img'{.'.png "alt =" using ecshop-based mobile terminal etouch to dynamically retrieve the list of classified products ". $ vo ['goods _ name']. '"/>';/* $ sayList [] = array ('pro-inner '=>'

. $ Vo ['URL']. '">. $ config ['site _ url']. $ vo ['goods _ thumb']. '"alt =" using ecshop-based mobile terminal etouch to dynamically retrieve the list of classified products ". $ vo ['goods _ name']. '">

. $ Vo ['URL']. '">'. $ vo ['name'].'

'. $ Shop_price .'

'. $ Vo ['market _ price'].'

Monthly sales:'. $ Vo ['sales _ count'].'

'. $ Watermark_img .'

'); */$ CollectStr = ''; if ($ vo ['collect']) {// If you have already searched for it, $ collectStr = '$ vo ['goods _ id']. ') "> Comment';} else {// if no search is found, $ collectStr = '$ vo ['goods _ id']. ') "> Comment';} $ sayList [] = array ('pro-inner '=> '. $ vo ['URL']. '">. $ config ['site _ url']. $ vo ['goods _ thumb']. '"alt =" using ecshop-based mobile terminal etouch to dynamically retrieve the list of classified products ". $ vo ['goods _ name']. '">

'. $ Vo ['name'].'

'. $ Shop_price .'

Monthly sales: '. $ vo ['sales _ count'].'

'. $ CollectStr .'

. $ Vo ['goods _ id']. '"> response

') ;}} Echo json_encode ($ sayList); exit ;}

There is also a function called category_get_goods. this function adds a field collect returned field that can be used to determine whether a search has been found and whether to display different styles and bind different event functions

/*** Get the product under the category ** @ 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 ($ mi N> 0) {$ where. = "AND g. shop_price >=$ min ";} if ($ max> 0) {$ where. = "AND g. shop_price <= $ max ";}/* get product list */$ 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. prom Ote_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;}/* process product watermark image */$ 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'] ['ma Rket_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']); // displays the monthly sales volume by wangif (isset ($ _ SESSION ['User _ id']) | $ _ SESSION ['User _ id']! = 0) {/* check whether it already exists in your favorites */$ 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 item to favorites */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");}/*** process feedback information of collected 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 = 'hangzhou';} 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 = 'hangzhou ';} // The plug-in is successfully added here. // note that a plug-in based on zepto mobile function library is introduced here. please refer to the code Zepto ('body '). popup ({title: 'prompt information', id: 'alert ', closeOnOk: true, OK:' OK ', message: result. message });}

Summary

I used to like php for a while, so the php code is basically understandable. mysql has also learned
Kids shoes without php Basics can learn php Basics first
At present, bloggers are dedicated to developing front-end backend and learning about the new APIs of javascript and html5 recently.
Record 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) ;}) ;}; script

    The above introduces the ecshop-based mobile terminal etouch to achieve dynamic acquisition of the list of classified products, including the content, hope to be helpful to friends interested in PHP tutorials.

    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.