zdcms做包含多模块的网站时,想要把已安装模块的名称和url列表循环出来语句应该如何写呢?
请看下面代码:
循环输出已安装的模块
{cache name=module-content}
名称:{$t.name}
地址:{$t.url}
图标:{$t.icon}
目录:{$t.dirname}
{if MOD_DIR == $t.dirname}
表示是当前模块
{/if}
{/cache}显示顺序受后台排序值而定,如下图:

如果需要指定输出某个模块的URL(限于独立模块)用下面的标签:
{dr_module_url("demo")}如需调用当前模块名称和URL可参考:zdcms站点URL和模块名称及url地址调用标签
如果需要把多个模块名称循环出来带入到多模块{modules}中查询数据,可以参考下面代码:
<?php
$rt = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
foreach ($rt as $key => $value) {
$module[] = $key;
}
$mod = implode(",",$module);
?>
{modules module=$mod field=title,catid,url,updatetime,description,hits order=updatetime}
{$t.title} {$t.url}
{/modules}
上面的情况中,如果想要排除某个模块,可以使用下面代码:
//排除news模块
<?php
$rt = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
foreach ($rt as $key => $value) {
if ($key != 'news') {
$module[] = $key;
}
}
$mod = implode(",",$module);
?>
{modules module=$mod field=title,catid,url,updatetime,description,hits order=updatetime}
{$t.title} {$t.url}
{/modules}如果你有类似的需求就试试看吧。