Zblog call the relevant article label example

Source: Internet
Author: User
Tags comments rand

The method is many, here the small series chooses three kinds, the first kind is zblog the official comparison recommendation method, the code is as follows:

{$aid = $article. ID}
{$tagid = $article. Tags}
{$cid = $article. Category.id}
{PHP}
$str = ';
$TAGRD =array_rand ($tagid);
if (sizeof ($tagid) >0 && ($tagid [$tagrd]->count) >1) {
$tagi = '%{'. $tagrd. '} %';
$where = Array (' = ', ' log_status ', ' 0 '), array (' Like ', ' Log_tag ', $tagi), Array (' <> ', ' log_id ', $aid));
}else{
$where = Array (' = ', ' log_status ', ' 0 '), array (' = ', ' Log_cateid ', $cid), Array (' <> ', ' log_id ', $aid));
}
$array = $zbp->getarticlelist (Array (' * '), $where, Array (' rand () ' => '), Array (6), ');
foreach ($array as $related) {
if (($related->id)!= $aid) {
$str. = "<li><span class=\" time\ ">{$related->time (' m-d ')}</span><span class=\" Title\ "> <i class=\ "icon-doc-text\" ></i><a href=\ "{$related->url}\" title=\ "{$related->title}\" >{$ Related->title}</a></span><small class=\ "pcomm\" ><i class=\ "icon-comment-1\" ></i > <a href=\ "{$related->url} #comments \" rel=\ "nofollow\" title=\ "comments on {$related->title}" >{$ Related->commnums}</a></small></li> ";
}
}
{/php}
{$STR}

The second one uses the zblogphp "GetList" function, the code reads as follows:

{foreach GetList (10,null,null,null,null,null,array (' is_related ' => $article. ID)) as $related}
<li><span>{$related. Time (' y-m-d ')}</span><a href= "{$related. URL} ">{$related. Title}</a></li>
{/foreach}

Place the above code in the "post-single.php" file in the subject you are using, and generally recommend "{$article. Content} "below, you can define CSS yourself."

You can also write the relevant article in the theme of the call code, the code is as follows:


{PHP}
$relatedpad = ';
$relatedtxt = ';
$numm = $zbp->config (' Duxx ')->related;//duxx as the ID of the subject
if (GetList ($numm, Null,null,null,null,null,array (' is_related ' => $article->id))) {
$array = GetList ($numm, Null,null,null,null,null,array (' is_related ' => $article->id));
}else{
$array = GetList ($numm, $article->category->id);
}
foreach ($array as $related) {
Sf_img1::getpics ($related, 181,111,4);
if ($related->sf_img_count>0) {
$rimg = $related->sf_img[0];
}else{
$rimg = $zbp->host ' zb_users/theme/duxx/style/img/random/'. Rand (1,20). JPG ';
}
$relatedpad. = ' <li><a href= '. $related->url. ' title= '. $related->title. ' " >$relatedtxt. = ' <li><a href= '. $related->url. ' title= '. $related->title. ' " ></a></li> ';
}
{/php}

Of course, we can also use the third party "related article" plug-in to replace the zblogphp original related article features. More recommended plug-ins have "Baidu recommended", "Friends recommend". We can choose the relevant article function according to our own demand

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.