门户首页指定id调取板块 跟 首页随机代码有冲突

chtws0012023-03-02  418

门户首页指定板块id调取 跟 首页随机代码有冲突

同时有这个代码的话,只显示随机,指定id调取就空白

只能二选一

--------------------------------

随机代码

<?php $arrlist = thread_tid_find(1, 5000);
if ($arrlist) {
    $threads = count($arrlist);
    $total = $threads > 20 ? 20 : $threads;
    $tidarr = $threads > 20 ? array_rand($arrlist, $total) : array_keys($arrlist);
    $arrlist = well_thread_find_asc($tidarr, $total);
}
?>
<?php if($arrlist){ ?>
<div class="shadow mt-3">
    <div class="card-header bg-light">
        <h3 class="h6 font-weight-bold my-0">
            随机推荐
        </h3>
    </div>
    <ul class="list-group list-group-flush">
        <!-- 循环输出主题 开始 -->
        <?php foreach($arrlist as $_thread) { ?>
        <li class="list-group-item bg-white">
            <h4 class="h6 my-0">
                <!-- 主题链接 -->
                <a href="<?php echo $_thread['url'];?>" class="d-block text-truncate" <?php echo (10==$_thread['type']?'rel="nofollow" target="_blank"':''); ?> title='<?php echo $_thread['subject'];?>' aria-label='<?php echo $_thread['subject'];?>'>
                    <!-- 主题 -->
                    <?php echo $_thread['subject'];?>
                </a>
            </h4>
        </li>
        <?php } ?>
        <!-- 循环输出主题 结束 -->
    </ul>
</div>
<?php } ?>

--------------------------------

指定id调取

<?php $_forum = $arrlist['list'][1]; { ?>
           <div class="col-lg-6 col-sm-12">
           <h3 class="section-title d-flex align-items-center mb-lg-4 mb-2">
             <a href="<?php echo $_forum['url'];?>" title='<?php echo $_forum['name'];?>'>
              <?php echo $_forum['name']; ?>
             </a>
           </h3>
             <div class="cms_grid_list">
             <?php if (!empty($_forum['news'])) {$i=0; foreach ($_forum['news'] as $_thread) {if ($_thread['icon_fmt'] && ++$i <= 5) { ?>
             <article class="post post-list">     
               <div class="entry-media"><div class="placeholder" style="padding-bottom: 66.666666666667%"><a href="<?php echo $_thread['url'];?>" title="<?php echo $_thread['subject'];?>" rel="nofollow noopener noreferrer"><img class=" lazyload" data-src="<?php echo $_thread['icon_fmt'];?>" src="<?php echo view_path();?>template/t/img/titibear-ing.gif" alt="<?php echo $_thread['subject'];?>"></a></div></div>                            
                <div class="entry-wrapper">
                 <header class="entry-header">
                  <h2 class="entry-title"><a href="<?php echo $_thread['url'];?>" title="<?php echo $_thread['subject'];?>" rel="bookmark"><?php echo $_thread['subject'];?></a></h2>
                 </header>
                <div class="entry-footer">
                  <div class="entry-meta">
            
                    <span class="meta-date">
                    <time datetime="<?php echo date('Y-m-d', $_thread['create_date']);?>">
                    <i class="fa fa-clock-o"></i>
                    <?php echo date('Y-m-d', $_thread['create_date']);?>
                    </time>
                    </span>

                 </div>
                </div>
                </div>
              </article>
              <?php }}} ?>
              </div>
            </div>
            <?php } ?>

转载请注明原文地址:https://www.wellcms.net/read-618.html
00
最新回复(1)
  • 这是数据被覆盖了,$arrlist = thread_tid_find(1, 5000);  $arrlist 自己要修改成别的,把下面的代码覆盖了,肯定调用不到数据了。
    回复00