[php]代码库
今天给客户做项目的时候,客户需求是友情链接可以分类,然后在分别调取分类下的友情链接,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']);
return 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}
{$type_v[name]}
//B5教程网 http://www.bcty365.com
{pc:link action="lists" typeid="$type_v['type_id']" siteid="$siteid" linktype="1" order="desc" num="20" return="dat"}
{loop $dat $v}
{$v['name']}|
{/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}
{$v['name']}|
{/loop} {/pc}
{/loop}
{/pc}
转自【B5教程网】:http://www.bcty365.com/content-101-1840-1.html