zblog,wordpress建站源码,探路者OZHO.cn

zblog,wordpress建站源码,探路者OZHO.cn

相关文章调用,如果文章没有图片,随机调用预先上传图片

<ul class="related"><span><h1>相关文章</h1></span>
                      {php}
                        $related = $zbp->GetArticleList('*', array(array('=', 'log_Type', 0), array('=', 'log_Status', 0)), array('log_PostTime' => 'DESC'), 5, null,false);
                       {/php} {foreach GetList(5,$article.Category.ID) as $related}
                     
                    <li  style="float:left; width: 15%; height: 200px;padding: 12px; ">
                      
                            <img src="
                      {php}
               $randimg=rand(1,4);
              $pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/";
              $content = $related->Content;
                          preg_match_all($pattern,$content,$matchContent);
                              if(isset($matchContent[1][0]))
                             $randimg=$matchContent[1][0];
                             else
                             $randimg="$host/zb_users/theme/default/style/default/$randimg.jpg";
                              {/php}
                            {$randimg}"
                            class="pic" width="100%" title="{$related.Url}" height="50%" alt="{$related.Url}"
                            pagespeed_url_hash="3167944164">
                        </a>
                        <a href="{$related.Url}" title="{$related.Title}">

          {$related.Title}	</a>
                       
                    </li>
                 {/foreach}
                </ul>


zb_users/theme/default/style/default 在此文件夹内上传4张图片,名称为1.jpg,2.jpg,3.jpg,4.jpg

上一篇:css图片与文字水平对齐

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

网站分类
搜索
最新留言
    文章归档