PHP Framework queryphp Lesson: Getting started seven assigning a template

Source: Internet
Author: User
PHP Framework queryphp Tutorial: Getting started seven assigning a template

You can use the Smarty template engine, see the Core/view.php class

However, it is best not to use the Smarty class, directly using PHP native template tags, because you can also assign objects to the template. such as the pager facet class.

Assignment Example:

Class Productsrouter extends controller{?

? function index ()?

? {?

? ? ? Return false;?

? }?

? Public function Show () {?

? ? ? $id =intval ($_get[' proid ');?

? ? if ($id! = ")?

? ? {?

? ? ? $pro =m ("products");

? ? ? $pro->get ($id);?

? ? ? Assign values to $proshow in a template?

? ? ? $this->proshow= $pro->edit ()->getdata ();?

? ? ? if ($pro->getpdflist1 ()! = ")?

? ? ? {?

? ? ? ? $pdflist =explode (",", $pro->getpdflist1 ());?

? ? ? ? $sql = ';?

? ? ? ? if (Is_array ($pdflist))?

? ? ? ? {?

? ? ? ? ? foreach ($pdflist as $key = $value)?

? ? ? ? ? {?

? ? ? ? ? ? $sql. =intval ($value). ",";?

? ? ? ? ? }?

? ? ? ? ? if ($sql! = ")?

? ? ? ? ? {?

??????. $sql =substr ($sql, 0,-1);??

??????. $yangben =m ("Yangben");?

???????//The $pdflist assignment in the template, where is the array?

??????? $this->assign ("Pdflist", $yangben->select ("Yangid,yangname,pdfimage")->wherein ("Yangid", $sql)- >fetch ()->getrecord ());?

? ? ? ? ? }?

? ? ? ?}?

? ? ? }?

? ? ? Product navigation part content output?

? ? ? $nav =DM ("Navpro");?

? ? ? $this->assign ("NavBar", $nav->gettree ());?

? ? }?

? }?

? Public Function prolist () {?

? ? Product navigation part content output tree output?

? ? ? $nav =DM ("Navpro");?

? ? $this->assign ("NavBar", $nav->gettree ());?

? ? $pro =m ("products");

? ? $smallid =intval ($_get[' smallid ');?

? ? $count = $pro->where ("ClassID", $smallid)->count ();?

? ? Assign a value to a template directly to an image?

? ? $this->pager=c ("pager");?

? ? $this->pager->setpager ($count, 10); The default is to use $_get[' page '] to get the page number of pages can be like this is the same setpager ($count, ten, ' page ');

? ? Assign a value to the template, list for the table of Contents//above the WHERE ("ClassID", $smallid), so there is no setting. Because the default number of gains does not clear the query criteria, the other clears

? ? $this->list= $pro->select ("id,classid,typeno,title,dest,ico,img")->orderby ("id desc")->limit ($this- >pager->offset (),->fetch ()->getrecord ();?


? ? $this->assign ("Smallid", $smallid);?

? }?

}?

?

Using pager objects in templates

Getwholebar (Url_for ("Products/prolist/smallid/". $smallid. " /page/:p Age "));?>


  • 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.