ECSHOP tutorial-call classification article, _ PHP Tutorial

Source: Internet
Author: User
ECSHOP Tutorial: call classification document ,. The ECSHOP tutorial calls classified articles. in the past few days, we have helped a friend create a mall using ECSHOP. I feel that the ECSHOP function is really powerful, but for those who do not understand the program, use the ECSHOP tutorial to call classified articles,

In the past few days, I have helped a friend create a mall using ECSHOP. I feel that the ECSHOP function is really powerful, but for those who do not know the program, it is still quite complicated to use, A slight modification will incur a great deal of twists and turns, and it would be nice to have a set of tag libraries as easily as it would be.

For example, when using deep blue, you need to call the article by category. this is a very common function, which is not provided Officially. you have to find a solution and finally find a solution. Please take a lookECSHOP tutorial

Implementation method:
For example, the homepage call method:
1. open the index. php file and find the following code:

$ Smarty-> assign ('New _ articles ', index_get_new_articles (); // The latest article



Add the following to it:

// Call method $ smarty-> assign ('class _ articles_4 ', index_get_class_articles (); // call the document by category // modify the parameters that are passed in after multiple calls, and the variables received by the template. the above 4 is the document Category ID, where 6 is the number of calls $ smarty-> assign ('class _ articles_5 ', index_get_class_articles (5, 6 )); // Classification call document $ smarty-> assign ('class _ articles_6 ', index_get_class_articles (6, 6); // Classification call document $ smarty-> assign ('class _ articles_7 ', index_get_class_articles (); // class Call document $ smarty-> assign ('class _ articles_8 ', index_get_class_articles (); // class Call document

// At the end?> Before that, add the following function index_get_class_articles ($ cat_aid, $ cat_num) {$ SQL = "SELECT article_id, title, open_type, cat_id, file_url FROM ". $ GLOBALS ['ecs']-> table ('article '). "WHERE cat_id = ". $ cat_aid. "and is_open = 1 LIMIT ". $ cat_num; $ res = $ GLOBALS ['DB']-> getAll ($ SQL); $ arr = array (); foreach ($ res AS $ idx => $ row) {$ arr [$ idx] ['id'] = $ row ['article _ id']; $ arr [$ idx] ['title'] = $ row ['title']; $ arr [$ idx] ['Short _ title'] = $ GLOBALS ['_ CFG'] ['article _ title_length ']> 0? Sub_str ($ row ['title'], $ GLOBALS ['_ CFG'] ['article _ title_length ']): $ row ['title']; $ arr [$ idx] ['cat _ name'] = $ row ['cat _ name']; $ arr [$ idx] ['add _ time'] = local_date ($ GLOBALS ['_ CFG'] ['date _ format'], $ row ['add _ time']); $ arr [$ idx] ['URL'] = $ row ['open _ type']! = 1? Build_uri ('article', array ('aid '=> $ row ['article _ id']), $ row ['title']): trim ($ row ['File _ url']); $ arr [$ idx] ['cat _ url'] = build_uri ('article _ cat ', array ('acid '=> $ row ['cat _ id']);} return $ arr ;}



2. the second step is to add the following code to the place where the index. dwt template is to be called (note: The following is a list of articles whose Category ID is 8 in the preceding settings ):

        
  • "{$article.url}" title="{$article.title|escape:html}">


  • The preceding method is successfully called.

    Sorry, I have helped a friend create a shopping mall in the past few days. I feel that the ECSHOP function is really powerful, but for those who do not know the program, it can be used...

    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.