比如:首页、列表、内容
头部模板是否可以做不一样的
比如官方这个头部模板
首页:1.2都调用
列表:只调用2。1就不用了
这样的情况怎么处理,高手们指点下
头部代码可以直接写在模板中,以下代码是我的一个模板的首页头部代码与栏目头部代码:
首页头部代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>{block name="head_title"}{$webdb.seo_title}手机版{/block}</title> <meta name="keywords" content='{block name="head_keword"}{$webdb.seo_keyword}{/block}'> <meta name="description" content='{block name="head_description"}{$webdb.seo_description}{/block}'> <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <script type="text/javascript" src="__STATIC__/js/core/jquery.min.js"></script> </head> <body> <!--下面是钩子插件,做风格的时候尽量加上,方便扩展--> {:hook_listen('layout_body_head',$userdb,$webdb,true)} <link href="__STATIC__/index/wap/static/css/wapindex.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="__STATIC__/index/wap/static/js/umeiapp.js"></script> <div n="head" class="header"> <div class="head-bar"><a href="/" class="head-logo l head-logo-article"></a></div> <h1 class="head-index-tit">{$webdb.webname}手机版</h1> <div class="head-right"><a m="nav" class="head-btn head-nav"></a></div> </div> <div n="nav" class="nav"> <dl> <dt><a href="/">{$webdb.webname}</a></dt> {volist name=":sort_config('cms',0)" id="name"} <dd><a href="{:urls('cms/content/index',"fid=$key")}">{$name}</a></dd> {/volist} </dl> </div>
栏目头部代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>{$s_info.name}{block name="head_title"}{$webdb.seo_title}手机版{/block}</title> <meta name="keywords" content='{block name="head_keword"}{$webdb.seo_keyword}{/block}'> <meta name="description" content='{block name="head_description"}{$webdb.seo_description}{/block}'> <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> {block name="head_base_css"}<link rel="stylesheet" href="__STATIC__/css/base.css">{/block} {block name="head_qb_ui"}<link rel="stylesheet" href="__STATIC__/css/qb_ui.css">{/block} {block name="head_font_icon"}<link rel="stylesheet" href="__STATIC__/icon/icon.css">{/block} {block name="head_jquery_js"}<script type="text/javascript" src="__STATIC__/js/core/jquery.min.js"></script>{/block} {block name="head_layer_js"}<script type="text/javascript" src="__STATIC__/layer/layer.js"></script>{/block} </head> <body> <!--下面是钩子插件,做风格的时候尽量加上,方便扩展--> {:hook_listen('layout_body_head',$userdb,$webdb,true)} <style type="text/css"> .qb_wap_header{ padding:12px 8px 4px 8px; background:#62B3E7; color:#fff; height:26px; } .qb_wap_header a{ color:#fff; } .qb_wap_header div{ float:left; } .qb_wap_header{ text-align:center; } .qb_wap_header .R{ float:right; } </style> {block name="body_Headcont"} <div class="qb_wap_header"> <div class="L" onclick="Qibo.goBack('/');"><i class="fa fa-reply"> 返回</i></div> {if M('name')} {:M('name')} {else /} {$webdb.webname} {/if} <div class="R" onclick="window.location.href='{:get_url('member')}'"><i class="fa fa-user-circle-o"> 会员</i></div> </div> {/block} <!--<link rel="stylesheet" href="__STATIC__/group/index.css"> <div class="MainContainer"> <div class="SearchBox"> <form method="POST" action="{:urls('search/index/lists')}"> <ul> <ol><input name="keyword" type="text" placeholder="请输入关键字"/></ol> <li><button type="submit"><i class="fa fa-search"></i></button></li> </ul> </form> </div>--> <!--分类开始--> <!--<style type="text/css"> .MainMenu{ margin-top:8px; background: #FFF; padding: 15px 10px; } .MainMenu ul:after{ content: ''; display:block; clear: both; } .MainMenu ul li{ width:25%; float: left; overflow: hidden; position: relative; margin-bottom:5px; } .MainMenu ul li span,.MainMenu ul li em{ display: block; width:60px; overflow: hidden; margin: auto; text-align: center; position: relative; } .MainMenu ul li span{ border-radius: 50%; background: #23C075; color: #FFF; } .MainMenu ul li em{ height: 20px; overflow: hidden; font-size:14px; } .MainMenu ul li:nth-child(2) span{ background: #F90; } .MainMenu ul li:nth-child(3) span{ background: #B01FE0; } .MainMenu ul li:nth-child(4) span{ background: #133CD7; } .MainMenu ul li span:before{ content: ''; display: block; padding-top: 100%; } .MainMenu ul li span i{ position: absolute; left:50%; top: 50%; font-size:30px; -webkit-transform: translate3D(-50%, -50%, 0); -ms-transform: translate3D(-50%, -50%, 0); transform: translate3D(-50%, -50%, 0); } </style> <div class="MainMenu"> <ul> {php}$menu_choose=config('system_dirname')?config('system_dirname'):'index';{/php} {volist name="pc|get_web_menu" id="rs"} <li {if ($rs['activate']==$menu_choose||$rs['activate']==$menu_choose.'-'.$fid)}class="ck"{/if}><a href="{$rs.url}">{$rs.name}</a></li> {/volist} </ul> </div>--> <!--分类结束-->
{extend name="$index_style_layout" /}
本来很简单的, 可能大家都不太会.晚点再出个教程吧
可以的.列表页继承另一个模板就可以了. 或者是不要继承任何模板.所有代码都在当前页面