2024年04月05日 建站教程
利用织梦建站,如何调用当前文章的副栏目名称及副栏目url地址,下面web建站小编给大家简单介绍一下具体实现代码!
function get_url_by_typeid2($typeid2) { if ($typeid2 == 0) { return ''; } else { $arrs = explode(",", $typeid2); //解析副栏目字段 $url = ''; foreach($arrs as $v) { $url. = '<a href="'.dede_typeurl($v).'">'.get_typename($v).'</a>'." "; } return $url; } } //织梦根据栏目编号typeid调用typename栏目名 function get_typename($typeid) { global $dsql; $rs = $dsql - >getOne("select typename from dede_arctype where id='$typeid'"); return $rs['typename']; }
文章页面调用方法:
[field:typeid2 function="get_url_by_typeid2(@me)"/]
方法二:
function get_url_by_typeid2($typeid2) { if ($typeid2 == 0) { return ''; } else { $arrs = explode(",", $typeid2); //解析副栏目字段 $url = ''; foreach($arrs as $v) { $url. = '<a href="'.get_typedir($v).'">'.get_typename($v).'</a>'." "; } return $url; } } //利用typeid调用typename栏目名 function get_typename($typeid) { global $dsql; $rs = $dsql - >getOne("select typename from ym_arctype where id='$typeid'"); return $rs['typename']; } //利用编号typeid调用url链接地址 function get_typedir($typeid) { global $dsql; $web = $dsql - >getOne("select value from ym_sysconfig where aid='1'"); $rs = $dsql - >getOne("select typedir from ym_arctype where id='$typeid'"); return str_replace("{cmspath}", $web['value'], $rs['typedir']); }
本文链接:http://so.lmcjl.com/news/1193/