PHP framework queryphp course: Getting started 7 assigning values to the template

Source: Internet
Author: User
Tags smarty template
PHP framework queryphp Tutorial: Getting started 7. you can use the smarty template engine to assign values to the template. for details, see core/view. php class, but it is best not to use the smarty class, directly use the php native template label, because the template can also be assigned an object. For example, pager classification. Assignment example: & lt ;? P PHP framework queryphp Tutorial: Getting started 7 assigning values to the template

You can use the smarty template engine. For more information, see core/view. php.

However, it is best not to use the smarty class, but to directly use the php native template tag, because the template can also be assigned an object. For example, pager classification.

Assignment example:

Get ($ id );???? // Assign a value to $ proshow in the template ???? $ This-> proshow = $ pro-> edit ()-> getData ();???? If ($ pro-> getasklist1 ()! = '')???? {????? $ Pdflist = explode (",", $ pro-> get1_list1 ());????? $ SQL = '';????? If (is_array ($ pdflist ))????? {?????? Foreach ($ pdflist as $ key => $ value )?????? {??????? $ SQL. = intval ($ value ).",";?????? }?????? If ($ SQL! = '')?????? {???????? $ SQL = substr ($ SQL, 0,-1 );? ???????? $ Yangben = M ("yangben ");???????? // Assign a value to $ pdflist in the template, which is an array ???????? $ This-> assign ("pdflist", $ yangben-> select ("yangid, yangname, shortimage")-> whereIn ("yangid", $ SQL)-> fetch () -> getRecord ());?????? }???? ?}???? }???? // What is the output of some content in the product navigation bar ???? $ Nav = DM ("navpro ");???? $ This-> assign ("navbar", $ nav-> getTree ());??? }?? }?? Public function prolist (){??? // What is the output tree output of some content in the product navigation bar ???? $ Nav = DM ("navpro ");??? $ This-> assign ("navbar", $ nav-> getTree ());??? $ Pro = M ("products ");??? $ Smallid = intval ($ _ GET ['smallid']);?? $ Count = $ pro-> where ("classid", $ smallid)-> count ();??? // Directly assign an image to the template ??? $ This-> pager = C ("pager ");??? $ This-> pager-> setPager ($ count, 10 ); // The default value is to use $ _ GET ['Page'] to retrieve the page number. this can be the same as setPager ($ count, 10, 'page ');?? // Assign a value to the template, and the list is the content list. // The where ("classid", $ smallid) is set above, so you do not need to set it below. Because the total number obtained by default does not clear the query conditions, other will clear?? $ This-> list = $ pro-> select ("id, classid, typeno, title, dest, ico, img")-> orderby ("id desc ") -> limit ($ this-> pager-> offset (), 10)-> fetch ()-> getRecord ();?
? ? $ This-> assign ("smallid", $ smallid );?? }?}???>?

Use pager objects in the template

GetWholeBar (url_for ("products/prolist/smallid/". $ smallid. "/page/: page");?>

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.