zblog 万能标签代码

风中赏雪 Zblog Zblog 2025-09-27 145 0

  {php}

{php}
function zbp_thumbnail($related) {
    global $zbp;
    $temp = mt_rand(1, 4);
    $pattern = "/<&#91;img|IMG&#93;.*?src=&#91;\'|\"&#93;(.*?(?:&#91;\.gif|\.jpg|\.png&#93;))&#91;\'|\"&#93;.*?&#91;\/&#93;?>/";
    $content = $related->Content;
    preg_match_all($pattern, $content, $matchContent);
    if (isset($matchContent[1][0])) {
        $thumb = $matchContent[1][0];
    } else {
        $thumb = $zbp->host . "zb_users/theme/" . $zbp->theme . "/include/random/" . $temp . ".jpg";
    }
    return $thumb;
}
 
 $alist =GetList(array('count'=>20,'cate'=>2,'order_custom' => array('log_UpdateTime' => 'DESC','log_PostTime'=>'DESC')));//每个分类都自己设置一个cate的值
 $i=0;


foreach($alist as $article){
if($i<2){
        // 获取缩略图
        $thumbnail = zbp_thumbnail($article);
echo '
<li class="jjaeffj top">
                <figure class="debbaef thumbnail">
                    <a href="'.$article->Url.'" title="'.$article->Title.'">
                        <img src="' . $thumbnail . '" alt="'.$article->Title.'" />
                    </a>
                </figure>
                <div class="edddgcc info">
                    <h4><a href="'.$article->Url.'" title="'.$article->Title.'">'.$article->Title.'</a></h4>
                    <div class="ifaicdc intro">'.$article->Intro.'</div>
                    <div class="dbfibge meta">
                        <time pubdate="'.$article->Time.'">'.$article->Time('Y-m-d').'</time>
                    </div>
                </div>
            </li>
            ';
//echo getFirstImageFromContent($article->Content);//获得图片连接
}else{
// 后8篇文章的代码
            echo '
            <li class="fbgciic list">
                <time pubdate="'.$article->Time.'">'.$article->Time('Y-m-d').'</time>
                <a href="'.$article->Url.'" title="'.$article->Title.'">'.$article->Title.'</a>
            </li>
            ';

}
$i++;
}

{/php}


      </section>
      <!-----新的函数规则插入--->
      
      
         		<section class="hbcfbjh box newsbox"> 
       <h3 class="dcaffef boxTitle">新规则插入</h3> 
      
      <div>图片函数不动继续应用</div>
      {php}
      $n1_list =GetList(array('count'=>20,'cate'=>2,'order_custom' => array('log_UpdateTime' => 'DESC','log_PostTime'=>'DESC')));//每个分类都自己设置一个cate的值
 $n1=1;
 foreach($n1_list as $article){
 
 switch($n1){
    case 1:
$thumbnail = zbp_thumbnail($article);
    echo '
    文章1输出规则
    ';
    break;
    case 2:
$thumbnail = zbp_thumbnail($article);
    echo '
    文章2输出规则
    ';
    break;
    case 3:
$thumbnail = zbp_thumbnail($article);
    echo '
    文章3输出规则
    ';
    break;
    
    
    default :
    echo '
    
    其他文章输出规则,排除指定的,就是不指定
    ';
    break;
    
}
echo "<br>";
 $n1++;
 }
 {/php}
       </section>


{php}
function zbp_thumbnail($related) {
    global $zbp;
    $temp = mt_rand(1, 4);
    $pattern = "/<&#91;img|IMG&#93;.*?src=&#91;\'|\"&#93;(.*?(?:&#91;\.gif|\.jpg|\.png&#93;))&#91;\'|\"&#93;.*?&#91;\/&#93;?>/";
    $content = $related->Content;
    preg_match_all($pattern, $content, $matchContent);
    if (isset($matchContent[1][0])) {
        $thumb = $matchContent[1][0];
    } else {
        $thumb = $zbp->host . "zb_users/theme/" . $zbp->theme . "/include/random/" . $temp . ".jpg";
    }
    return $thumb;
}

$blist = GetList(array('count' => 20, 'cate' => 2, 'order_custom' => array('log_UpdateTime' => 'DESC', 'log_PostTime' => 'DESC')));
$j = 0;

foreach ($blist as $article) {
    if ($j < 2) {
        // 获取缩略图
        $thumbnail = zbp_thumbnail($article);

        echo '
        <li class="wlmqxbt top">
            <figure class="wlmqxbt thumbnail">
                <a href="' . $article->Url . '" title="' . $article->Title . '">
                    <img src="' . $thumbnail . '" alt="' . $article->Title . '" />
                </a>
            </figure>
            <div class="wlmqxbt info">
                <h4><a href="' . $article->Url . '" title="' . $article->Title . '">' . $article->Title . '</a></h4>
                <div class="wlmqxbt intro">' . $article->Intro . '</div>
                <div class="wlmqxbt meta">
                    <time pubdate="' . $article->Time . '">' . $article->Time('Y-m-d') . '</time>
                </div>
            </div>
        </li>
        ';
    } else {
        // 后8篇文章的代码
        echo '
        <li class="wlmqxbt list">
            <time pubdate="' . $article->Time . '">' . $article->Time('Y-m-d') . '</time>
            <a href="' . $article->Url . '" title="' . $article->Title . '">' . $article->Title . '</a>
        </li>
        ';
    }
    $j++;
}
{/php}