一、系统扩展函数文件phpcms\libs\functions\extention.func.php中添加函数:
/*
* @param $roleid 当前管理员角色ID
* @param $uid 当前管理员角色ID
* */
function get_username_from_tit($title){
$userlist = pc_base::load_model('admin_model');
$userinfo = $userlist->get_one(array('realname'=>$title));
return $userinfo['username'];
}
二、这里以show.html文章展示页模板为例:
<?php
$uname = get_username_from_tit($title);
$page = intval($_GET["page"]);
?>
{pc:get sql="SELECT * FROM `v9_news` where username = '$uname' order by listorder DESC,inputtime DESC" page="$page" num="8" return="data"}
<ul class="mt50 flex">
{loop $data $r}
<li>
<a href="{$r['url']}" title="{$r['title']}" target="_blank" class="flex">
<div class="com_news_date">{date('Y.m.d',$r['inputtime'])}</div>
<div class="com_news_txt">
<h5 class="elli">{$r['title']}</h5>
<p class="clamp">{$r['description']}</p>
</div>
</a>
</li>
{/loop}
</ul>
<div id="pages" class="flex_c">{$pages}</div>
{/pc}