Smarty Function-Inherit extents

Source: Internet
Author: User

Inheritance <{extends}>

    • {extends} tags are used in the first line of the template;
    • If the child template inherits the parent template with the {extends} tag, it can only contain the {block} tag (content), and any other template content will be ignored;

Backstage (zi.php)

<? PHP include (".. /init.inc.php "); include (".. /dbda.php "); $db New Dbda (); $smarty->assign ("Shouye", "Home"); $smarty->assign ("Chanpin", "Product"); $smarty->display ("zi.html");

Parent template (fu.html):

<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><title><{blockname= ' Biaoti '}>Parent Template<{/block}></title>//Head<{blockname= ' head '}><{/block}><styletype= "Text/css">#daohang{width:100%;Height:50px}. Menu{width:100px;Height:50px;Background-color:#66C;float: Left;text-align:Center;Line-height:50px;vertical-align:Middle}#footer{width:100%;Height:100px;Background-color:#F36}</style></Head><Body><DivID= "Daohang"><Divclass= ' Menu '><{$shouye}></Div><Divclass= ' Menu '><{$chanpin}></Div></Div>Main body:<Divstyle= "width:300px; height:200px"><{blockname= ' Neirong '}><{/block}></Div>Tail:<Divstyle= "width:100%; height:100px; Background-color: #CCC"><{blockname= ' di '}><{/block}></Div><DivID= "Footer"></Div></Body></HTML>

Child Template (zi.html):

<{extendsfile= ' fu.html '}>//Call function, the child template inherits everything from the parent template, the child has rewritten the parent, modified or appended with block tags, the order doesn't matter, and you want to change where to add the block tag<{blockname= ' Biaoti '}>//Modify Title sub-page<{/block}>Modify Style://To modify the style to have two parts<{blockname= ' head '}><styletype= "Text/css">#nr{width:200px;Height:200px;Background-color:#03F}</style><{/block}>//Style sheet Section<{blockname= ' Neirong '}>    <DivID= "NR"></Div><{/block}>//Modified Content Section<{blockname= ' di '}>the bottom of the page<{/block}>

Smarty Function-Inherit extents

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.