万户网络知识库 > 常见问题 > 单篇、列表页混合读取
单篇、列表页混合读取
更新时间:2019-03-12 09:54:33 访问量:
解决方案一
思路:
使用if置标判断内容模板是否被绑定,如果有绑定内容模版生成list页面,如果没有版定内容模版则生成index页面
代码:
<wtl:list sql="select * from Whir_Dev_Column where parentid=165 and isDel=0 and marktype is null order by sort asc,createdate desc">
<wtl:If TestType="{$ContentTemp}" TestOperate="Empty">
<SuccessTemplate>
<li><a id="menu{$ColumnID,parent}" href="{$sitepath}{$path,parent}/index_{$ColumnID,parent}.aspx">{$ColumnName,parent}</a></li>
</SuccessTemplate>
<FailureTemplate>
<li><a id="menu{$ColumnID,parent}" href="{$sitepath}{$path,parent}/list_{$ColumnID,parent}.aspx">{$ColumnName,parent}</a></li>
</FailureTemplate>
</wtl:If>
</wtl:list>
缺点:
如果我绑定了内容模版,但是我不需要list页面,只有详细页,上面的代码就不适用了
解决方案二(推荐)
思路:
<wtl:list sql="select * from Whir_Dev_Column where parentid=165 and isDel=0 and marktype is null order by sort asc,createdate desc">
<li><a id="menu{$ColumnID}" href="<%#Whir.Service.ServiceFactory.ColumnService.GetColumnListLink(Container.DataRow["ColumnID"].ToInt(),true,0)%>">{$ColumnName}</a></li>
</wtl:list>
<wtl:list sql="select * from Whir_Dev_Column where parentid=165 and isDel=0 and marktype is null order by sort asc,createdate desc">
<li><a id="menu{$ColumnID}" href="{$url,{$ColumnID}}">{$ColumnName}</a></li>
</wtl:list>
优点:
自动获取页面链接,不需要管绑定的是什么类型的模版
思路:
使用if置标判断内容模板是否被绑定,如果有绑定内容模版生成list页面,如果没有版定内容模版则生成index页面
代码:
<wtl:list sql="select * from Whir_Dev_Column where parentid=165 and isDel=0 and marktype is null order by sort asc,createdate desc">
<wtl:If TestType="{$ContentTemp}" TestOperate="Empty">
<SuccessTemplate>
<li><a id="menu{$ColumnID,parent}" href="{$sitepath}{$path,parent}/index_{$ColumnID,parent}.aspx">{$ColumnName,parent}</a></li>
</SuccessTemplate>
<FailureTemplate>
<li><a id="menu{$ColumnID,parent}" href="{$sitepath}{$path,parent}/list_{$ColumnID,parent}.aspx">{$ColumnName,parent}</a></li>
</FailureTemplate>
</wtl:If>
</wtl:list>
缺点:
如果我绑定了内容模版,但是我不需要list页面,只有详细页,上面的代码就不适用了
解决方案二(推荐)
思路:
<wtl:list sql="select * from Whir_Dev_Column where parentid=165 and isDel=0 and marktype is null order by sort asc,createdate desc">
<li><a id="menu{$ColumnID}" href="<%#Whir.Service.ServiceFactory.ColumnService.GetColumnListLink(Container.DataRow["ColumnID"].ToInt(),true,0)%>">{$ColumnName}</a></li>
</wtl:list>
<wtl:list sql="select * from Whir_Dev_Column where parentid=165 and isDel=0 and marktype is null order by sort asc,createdate desc">
<li><a id="menu{$ColumnID}" href="{$url,{$ColumnID}}">{$ColumnName}</a></li>
</wtl:list>
优点:
自动获取页面链接,不需要管绑定的是什么类型的模版