
首页门户,调用了全局置顶、首页自定义标签主题、设置为首页显示的版块主题和友情链接。
对应官方默认文件为view/htm/portal.htm,请勿修改这个文件,如需修改请按照模板开发说明操作。
图片轮播使用的是置顶主题。
对应变量 $arrlist 包含除友情链接外的全部数据。
array( //list栏目已经rank排序 'list' => array( 'fid' => array( 'fid' => fid, 'name' => name, 'rank' => rank, 'type' => type, 'url' => url, 'index_new' => 首页显示最新数量, // 栏目下主题二数组 'news' => array( 'tid' => array( // 主题数据 ) ), ), // flaglist 首页自定义标签下的主题数据 'flaglist' => array( flagid => array( 'tid' => thread // 主题数据 ) ), // flag 首页所有设置为显示的全部自定义标签下的主题数据 'flag' => array( 'tid' => thread // 主题数据 ), // 全局置顶数据 'sticky' => array( 'tid' => thread // 主题数据 ) ) );
//----------双图轮播代码------------
<?php if (!empty($slide)) { ?>
<div id="carouselExampleIndicators" class="carousel slide " data-ride="carousel">
<ol class="carousel-indicators">
<?php $n = count($slide) / 2;for ($i = 0; $i < $n; ++$i) { ?>
<li data-target="#carouselExampleIndicators" data-slide-to="<?php echo $i; ?>" <?php if($i == 0) {echo 'class="active"';} ?>></li>
<?php } ?>
</ol>
<div class="carousel-inner">
<?php $i = 0;foreach($slide as &$_thread) { $i++; ?>
<?php if ($i % 2 == 1) { ?>
<div class="carousel-item <?php if ($i == 1) {echo 'active';} ?>">
<div class="row">
<?php } ?>
<div class="col-6 <?php if ($i % 2 == 1) {echo 'pl-0 pr-1';} elseif ($i%2 == 0) {echo 'pl-1 pr-0';} ?>">
<a href="<?php echo $_thread['url'];?>">
<img class="d-block w-100 rounded" src="<?php echo $_thread['icon_text']; ?>" alt='<?php echo $_thread['subject'];?>'>
<!--
<div class="carousel-caption d-none d-md-block">
<h2><?php echo $_thread['subject'];?></h2>
</div>
-->
</a>
</div>
<?php if($i%2 == 0) { ?>
</div>
</div>
<?php } ?>
<?php } ?>
</div>
</div>
<?php } ?>//----------单图轮播代码------------
<?php if (!empty($slide)) { ?>
<div id="carouselExampleIndicators" class="carousel slide " data-ride="carousel"
<ol class="carousel-indicators">
<?php $n = count($slide);for ($i = 0; $i < $n; ++$i) { ?>
<li data-target="#carouselExampleIndicators" data-slide-to="<?php echo $i; ?>" <?php if($i == 0) {echo 'class="active"';} ?>></li>
<?php } ?>
</ol
<div class="carousel-inner">
<?php $i =0;foreach($slide as &$_thread) {++$i;?>
<div class="carousel-item <?php if ($i == 1) {echo 'active';} ?>">
<a href="<?php echo $_thread['url'];?>">
<img class="d-block w-100" src="<?php echo $_thread['icon_text']; ?>" alt='<?php echo $_thread['subject'];?>'>
<!--
<div class="carousel-caption d-none d-md-block">
<h2><?php echo $_thread['subject'];?></h2>
</div>
-->
</a>
</div>
<?php } ?>
</div>
</div>
<?php } ?>//----------轮播代码下方的主题------------
调用的是首页的自定义标签主题,你也可以换成自己需要调用的内容。
<ul class="list-unstyled threadlist ul_round nowrap">
<?php if (!empty($arrlist['flag'])) { ?>
<?php foreach($arrlist['flag'] as $_thread) { ?>
<li class="tap ml-2" data-href="<?php echo $_thread['url'];?>">
<h2 class="ellipsis">
<a href="<?php echo $_thread['url'];?>" title='<?php echo $_thread['subject'];?>' aria-label='<?php echo $_thread['subject'];?>'>
<?php echo $_thread['subject'];?>
</a>
</h2>
</li>
<?php } ?>
<?php } ?>
</ul>//----------上方中间导读 调用的是全局置顶------------
不懂的php代码直接复制到你的模板
<ul class="list-unstyled threadlist">
<?php if (!empty($arrlist['sticky'])) {foreach ($arrlist['sticky'] as $_thread) {if ($_thread['i'] <= 4 /* 4为显示数量,根据自己需要调整数字 */) { ?>
<li class="thread">
<h2 class="font-weight-bold break-all nowrap">
<a class="d-block ellipsis" href="<?php echo $_thread['url'];?>" title='<?php echo $_thread['subject'];?>' aria-label='<?php echo $_thread['subject'];?>'> <?php echo $_thread['subject'];?>
</a>
</h2>
<a href="<?php echo $_thread['url'];?>" title='<?php echo $_thread['subject'];?>' aria-label='<?php echo $_thread['subject'];?>'>
<p class="m-t-sm mb-1 text-grey break-all">
<?php echo $_thread['brief']?$_thread['brief']:lang('no_brief');?>
</p>
</a>
</li>
<?php }}} ?>
</ul>//----------上方右侧 调用的是排序为第一个自定义标签的专题------------
class:nowrap和ellipsis是控制字数超出,超出后则使用3个点代替后面信息
<div class="row nowrap mx-1 mt-3">
<?php if(!empty($first_flag)){foreach($first_flag as $_thread) { ?>
<div class="col-lg-12">
<a class="d-block ellipsis" href="<?php echo $_thread['url'];?>" title='<?php echo $_thread['subject'];?>' aria-label='<?php echo $_thread['subject'];?>'>
<?php echo $_thread['subject'];?>
</a>
</div>
<?php }} ?>
</div>下方调用各个设置为显示板块的主题,此部分代码为多维数组,对应的变量和参数为 $arrlist['list'] 循环输出,此处仅贴出数组形式,具体代码,请查看对应文件。
Array ( [38] => Array ( [fid] => 38 [name] => 新闻 [rank] => 2 [type] => 1 [url] => list-38.html [index_new] => 10 // 版块下最新主题数据 [news] => Array ( [5] => Array ( [tid] => 5 [fid] => 38 [forum_name] => 新闻 [subject] => 测试VIP [url] => read-5.html [tag] => [tag_text] => [sticky_class] => [icon] => 1577977955 [icon_text] => upload/thumbnail/202001/1_5_1577977955.jpeg [type] => 0 [sticky] => 0 [link] => 0 [uid] => 1 [views] => 0 [posts] => 0 [images] => 1 [files] => 0 [mods] => 0 [status] => 0 [closed] => 0 [lastuid] => 0 [brief] => [keyword] => [description] => [attach_on] => 0 [image_url] => [flags] => 0 [create_date] => 1577977955 [create_date_fmt] => 8天前 [create_date_text] => 2020-01-02 [last_date] => 1577977955 [last_date_fmt] => [lastusername] => [last_date_text] => 2020-01-02 [username] => admin [user_url] => user-1.html [user_avatar_url] => view/img/avatar.png [user] => Array ( [uid] => 1 [gid] => 1 [username] => admin [avatar] => 0 [articles] => 0 [comments] => 2 [groupname] => 管理员组 [avatar_url] => view/img/avatar.png [online_status] => 1 ) [pages] => 0 [allowupdate] => 1 [allowdelete] => 1 ) ) ) )
不使用循环输出,单独调用版块,方法为 $arrlist['list'][版块fid] 比如想调用版块 1 的数据则为 $arrlist['list'][1]
代码实现,仅需修改html部分,php代码部分保持不变。
<?php $_forum = $arrlist['list'][1];?>
<div class="card">
<div class="card-header">
<div class="row justify-content-between m-0">
<div>
<strong>
<a href="<?php echo $_forum['url'];?>" title='<?php echo $_forum['name'];?>'>
<?php echo $_forum['name']; ?>
</a>
</strong>
</div>
<div>
<a href="<?php echo $_forum['url'];?>">
<i class="icon-angle-double-right"></i>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<ul class="row list-unstyled threadlist nowrap pl-2 mb-0">
<?php if (!empty($_forum['news'])) {$i=0; foreach ($_forum['news'] as $_thread) {if ($_thread['icon_text'] && ++$i <= 2) { ?>
<li class="col-6 col-md-12 mt-3">
<a href="<?php echo $_thread['url'];?>">
<img class="d-block w-100" src="<?php echo $_thread['icon_text']; ?>" alt='<?php echo $_thread['subject'];?>'>
<div class="ellipsis">
<?php echo $_thread['subject'];?>
</div>
</a>
</li>
<?php }}}else{ ?>
<li class="col-md-12">
<img class="main-pic" src="<?php echo view_path();?>img/nopic.png" width="170" height="128">
<p class="p-2 m-0">
<?php echo lang('none');?>
</p>
</li>
<?php } ?>
</ul>
</div>
<div class="col-md-8">
<ul class="list-unstyled threadlist nowrap pt-3">
<!--最新内容-->
<?php if (!empty($_forum['news'])) { foreach ($_forum['news'] as $_thread) { ?>
<li class="col-lg-12 tap ellipsis" data-href="<?php echo $_thread['url'];?>">
<a href="<?php echo $_thread['url'];?>" title='<?php echo $_thread['subject'];?>'>
<h2 class="ellipsis">
<?php echo $_thread['subject'];?>
</h2>
</a>
</li>
<?php }} ?>
</ul>
</div>
</div>
</div>//----------友情链接------------
<?php if(!empty($linklist)){ ?>
<div class="card">
<div class="card-header"><?php echo lang('friends_link');?></div>
<div class="nav bg-white">
<?php foreach($linklist as &$_link) { ?>
<a href="<?php echo $_link['url'];?>" class="nav-link" target="_blank" aria-label='<?php echo $_link['name'];?>'>
<?php echo $_link['name'];?>
</a>
<?php } ?>
</div>
</div>
<?php } ?>//-------------- 页头导航栏 active 放在页面最下面 ---------------
<script>
$('#nav li[data-active="fid-<?php echo $fid;?>"]').addClass('active');
</script>加载公用的页头和页脚,这个页面就完成了。不懂php没关系,只要懂bootstrap和html、css就可以了,把官方 htm 文件里的php代码复制过去即可。
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, LeCMS, ClassCMS, Fastadmin, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。
未经允许不得转载:Str Tom工作室 » Wellcms,首页门户模式


