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 "));?>