添加步骤:
将以下代码添加到当前主题module.php文件中:
<?PHP
function related _ logs($ logData = array())
{
$ config file = em log _ ROOT。/content/plugins/related _ log/related _ log _ config . PHP ';
if(is _ file($ config file)){
require $ config file;
} else {
$ related _ log _ type = ' sort ';//相关日志类型,排序是分类,标签是日志;
$ related _ log _ sort = ' rand ';//排列,views_desc是点击数(降序)comnum_desc是评论数(降序)rand是随机views_asc是点击数(升序)comnum_asc是评论数(升序)
$ related _ log _ num = ' 10 ';//显示文章数量,排版只能是10
$ related _ inrss = ' y ';//是否在rss feed中显示,y为是,其他值为否
}
global $ value;
$ DB = MySql::getInstance();
$ CACHE = CACHE::getInstance();
extract($ logData);
if($ value)
{
$ logid = $ value[' id '];
$ sortid = $ value[' sortid '];
global $ abstract;
}
$ SQL = " SELECT GID,title FROM "。DB _前缀。" blog WHERE hide = ' n ' AND type = ' blog ' ";
if($ related _ log _ type = = ' tag ')
{
$ log _ CACHE _ tags = $ CACHE- gt;read cache(' log tags ');
$ Tag _ Model = new Tag _ Model();
$ related _ log _ id _ str = ' 0 ';
foreach($ log _ cache _ tags[$ logid]as $ key = gt;$ val)
{
$ related _ log _ id _ str。= ','.$ Tag _ Model- gt;getTagByName($ val[' tagname ']);
}
$sql。= "还有gid!=$logid和$related_log_id_str " "中的gid
} else {
$ SQL。= "还有gid!=$logid和sortid = $ sortid ";
}
switch($ related _ log _ sort)
{
case ' views _ desc ':
{
$ SQL。=“按DESC视图排序”;
break;
}
case ' views _ ASC ':
{
$ SQL。= "按视图排序ASC ";
break;
}
case ' comnum _ desc ':
{
$ SQL。=“由康姆ORDER订购”;
break;
}
case ' comnum _ ASC ':
{
$ SQL。= "按comnum ASC排序";
break;
}
case ' rand ':
{
$ SQL。= " ORDER BY rand()";
break;
}
}
$ SQL。= " LIMIT 0,$ related _ log _ num ";
$ related _ logs = array();
$ query = $ d b- gt;查询($ SQL);
while($ row = $ d b- gt;fetch _ array($ query))
{
$ row[' GID ']= intval($ row[' GID ']);
$ row[' title ']= htmlspecialchars($ row[' title ']);
$ related _ logs[]= $ row;
}
$ out =“”;
if(!empty($ related _ logs))
{
foreach($ related _ logs as $ val)
{
$ out。= " lt李 gt lta href=\ "。Url::log($val['gid']),"\ " gt{ $ val[' title ']} lt;/a gt; lt/李>;
}
}
if(!empty($ value[' content '])
{
if($ related _ inrss = = ' y ')
{
$ abstract。= $ out
}
} else {
echo $ out;
}
}
? gt
在喜欢的位置打开当前主题的echo_log.php文件,比如
然后通过CSS美化风格。以下展示风格供有需要的博主参考:
# art _ about { margin:10px 5px;填充:10px 0;溢出:隐藏;填充-底部:10px}
# art _ about b { margin:0 0px 5px 10px }
# art _ about ul { padding:10px;}
# art _ about ul Li {
行高:1.5em
float:left;
背景:url("images/dot.gif ")无重复滚动0px 50%透明;
左填充:15px
margin:5px 15px;
宽度:350px
white-sap ce:nowrap;
溢出:隐藏;
显示:内嵌;
}
以上代码摘自互联网。