今天给客户做项目的时候,客户需求是友情链接可以分类,然后在分别调取分类下的友情链接,phpcms v9友情链接在别的模板上无法调用的,于是自己就修改一下代码。
代码如下
phpcms/modules/link/classes/link_tag.class.php
public function type_lists($data) {
if (!in_array($data['listorder'], array('desc', 'asc'))) {
$data ['listorder'] = 'desc';
}
$sql = array('module'=>ROUTE_M,'siteid'=>$data['siteid']);
$r = $this->type_db->select($sql, '*', $data['limit'], 'listorder '.$data['listorder']);
retrn new_html_special_chars($r);
}
修改为:
public function type_lists($data) {
if (!in_array($data['listorder'], array('desc', 'asc'))) {
$data ['listorder'] = 'desc';
}
$sql = array('module'=>'link','siteid'=>$data['siteid']);
$r = $this->type_db->select($sql, '*', $data['limit'], 'listorder '.$data['listorder']);
return new_html_special_chars($r);
}
然后实例代码如下:
{pc:link action="type_lists" listorder="desc" siteid="$siteid"}
{loop $data $type_v}
<div class="map_main main">
<div class="m_map_fenlei">
<a href="{$r[url]}"> <span>{$type_v[name]}</span></a>
</div>
<div class="h10"></div>
<div class="m_map_lanmu">
<ul>
{pc:link action="lists" typeid="$type_v['type_id']" siteid="$siteid" linktype="1" order="desc" num="20" return="dat"}
{loop $dat $v}
<li><a href="{$v['url']}">{$v['name']}</a>|</li>
{/loop} {/pc}
{pc:link action="lists" typeid="$type_v['type_id']" siteid="$siteid" linktype="0" order="desc" num="20" page="$_GET[page]" return="dat"}
{loop $dat $v}
<li><a href="{$v['url']}">{$v['name']}</a>|</li>
{/loop} {/pc}
</ul>
<div class="h10 clear "></div>
</div>
<div class="h30 top_border map_main" ></div>
{/loop}
{/pc}
新闻热点
疑难解答