discuz 自定义不同栏目不同模板

本文特别鸣谢建站笔记http://www.cmsbj.cn/dzdm/t945.html大佬帮助,为方便以后使用,特此记录下来.
为了解决这个问题,小编几乎百度了几十页的内容,折腾几天最终是建站笔记大佬给帮助下解决了!再次感谢!
本功能不是选择“风格方案”,一个风格就够了。
!实现此功能需要动数据库。
操作:
1.为表pre_forum_forum添加两个字段:
ffile,主题列表模板
vfile,主题内容模板 手动添加或执行

ALTER TABLE `pre_forum_forum` ADD `ffile` CHAR( 40 ) NOT NULL AFTER `styleid` , ADD `vfile` CHAR( 40 ) NOT NULL AFTER `ffile`; 

2.添加后台表单 打开source/admincp/admincp_forums.php,找到

showsetting('forums_edit_extend_threadcache', 'threadcachesnew', $forum['threadcaches'], 'text');

其下添加

showsetting('forums_edit_extend_ffile', 'ffilenew', $forum['ffile'], 'text'); showsetting('forums_edit_extend_vfile', 'vfilenew', $forum['vfile'], 'text'); 

找到

'styleid' => $_GET['styleidnew']

其下添加

'ffile'=>$_GET['ffilenew'], 'vfile'=>$_GET['vfilenew'],

3.给主题列表模板增加判断
打开source/module/forum/forum_forumdisplay.php,
找到

$template = 'diy:forum/forumdisplay:'.$_G['fid'];

在其下增加:

$template2 = 'diy:'.$_G['forum']['ffile'].':'.$_G['fid'];

再找到

 include template($template);

注释掉,其下添加

if($_G['forum']['ffile'])
      $skinfile=$template2;
  else
      $skinfile = $template;
include template($skinfile); 

4.给主题内容模板增加判断
打开source/module/forum/forum_viewthread.php,
找到

include template('diy:forum/viewthread'.$sufix.':'.$_G['fid']);

注释掉,其下添加

if($_G['forum']['vfile']){ include template($_G['forum']['vfile']); } else{ include template('diy:forum/viewthread'.$sufix.':'.$_G['fid']); } 

5.给后台表单添加名称和说明
打开source/language/lang_admincp.php,
找到

forums_edit_extend_threadcache_comment

其下添加

'forums_edit_extend_ffile' => '主题列表模板文件:', 'forums_edit_extend_ffile_comment' => '填写格式如forum/forumdisplay,为空则默认为forumdisplay',
 'forums_edit_extend_vfile' => '版块内容模板文件:', 'forums_edit_extend_vfile_comment' => '填写格式如forum/viewthread,为空则默认为viewthread',

至此修改完成。
打开后台,版块编辑,扩展设置,页面缓存系数之下有新增的表单,按说明填写即可。
在这里插入图片描述

小贴士:业余选手不要去琢磨怎么调用指定风格的头部底部,费尽千辛万苦实现过。看似用的是同一个,但还是会出现找不到文件或变量或js的情况存在,这是错误的研究方向。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值