Discuz! 官方交流社區(qū)
標(biāo)題: 請問DZ可以實(shí)現(xiàn)自己寫一個(gè)單獨(dú)的頁面,然后調(diào)用DZ的模板嗎 [打印本頁]
作者: 一劍橫天 時(shí)間: 2022-9-26 22:50
標(biāo)題: 請問DZ可以實(shí)現(xiàn)自己寫一個(gè)單獨(dú)的頁面,然后調(diào)用DZ的模板嗎
請問DZ可以實(shí)現(xiàn)自己寫一個(gè)單獨(dú)的頁面,然后調(diào)用DZ的頭部和底部嗎?
作者: 可樂不加冰 時(shí)間: 2022-9-27 01:16
1.根目錄建立新文件命名 news.php- <?php
- define('CURSCRIPT', 'archy');//body的一個(gè)class標(biāo)識(shí)
- require './source/class/class_core.php';//引入系統(tǒng)核心文件
- $discuz = & discuz_core::instance();//以下代碼為創(chuàng)建及初始化對象
- $discuz->init();
- loadcache('diytemplatename');//DIY要載入緩存
- $navtitle = '影視輪播';
- $metakeywords = '單頁關(guān)鍵詞1,單頁關(guān)鍵詞2';
- $metadescription = '單頁的描述說明';
- include template('diy:forum/news');//調(diào)用單頁模版文件
- ?>
復(fù)制代碼 2.模板目錄(我的是默認(rèn)模板建立新文件命名news.htm)/template/default/forum/news.htm
- <!--{template common/header}-->
- <div id="pt" class="bm cl">
- <div class="z">
- <a href="./" class="nvhm" title="{lang homepage}">$_G[setting][bbname]</a><em>?</em>
- <a href="forum.php">$_G[setting][bbname]</a><em>?</em>
- <a href="javascript:;">$navtitle</a>
- </div>
- </div>
- <style id="diy_style" type="text/css"></style>
- <div class="wp">
- <!--[diy=diy2]--><div id="diy2" class="area"></div><!--[/diy]-->
- </div>
- <div id="ct" class="wp cl">
- <div class="mn bm cl">
- <div class="bm_c">
-
- <p style="width:300px; margin:10px auto; text-align:center;">這里是單頁正文內(nèi)容區(qū)域</p>
-
- </div>
- </div>
- </div>
- <!--{template common/footer}-->
復(fù)制代碼 3.實(shí)現(xiàn)頁面是這樣的
(, 下載次數(shù): 14)
作者: 人工智能實(shí)驗(yàn)室 時(shí)間: 2022-9-27 08:55
創(chuàng)建入口文件
在論壇根目錄下創(chuàng)建news.php文件,代碼如下
- <?php
- require_once './source/class/class_core.php';
- $discuz = C::app();
- $discuz->init();
- //這里是代碼邏輯
- include template('diy:common/addon_news');
復(fù)制代碼
創(chuàng)建模板
\template\default\common\目錄下創(chuàng)建addon_news.htm文件,代碼如下:
- <!--{template common/header}-->
- <div id="pt" class="bm cl">
- <div class="z">
- <a href="./" class="nvhm" title="{lang homepage}">$_G[setting][bbname]</a> <em>?</em>
- <a href="news.php">熱點(diǎn)新聞</a>
- </div>
- </div>
-
- <!--{ad/text/wp a_t}-->
- <style id="diy_style" type="text/css"></style>
- <div class="wp">
- <!--[diy=diy1]--><div id="diy1" class="area"></div><!--[/diy]-->
- </div>
- <div id="ct" class="ct2 wp cl">
- <!--在這里面寫入頁面中間內(nèi)容-->
- </div>
- <!--{template common/footer}-->
復(fù)制代碼
前臺(tái)訪問地址:http://域名/news.php
完成以上部分,一個(gè)大致的單頁框架就搭建起來了,剩下的就是完善自己的業(yè)務(wù)邏輯了!
二次開發(fā)的前提是你會(huì)php、mysql和html,如果都不會(huì)的話還是建議聯(lián)系開發(fā)者定制!
作者: 人工智能實(shí)驗(yàn)室 時(shí)間: 2022-9-27 09:52
奇了怪了,我回復(fù)的時(shí)候前面還沒呢,怎么8小時(shí)前了?剛審核通過的?
作者: 一劍橫天 時(shí)間: 2022-9-27 10:11
頁面比較多,因?yàn)槊總€(gè)頁面樣式不太一樣,所以沒打算用PHP寫,如果用html寫的話,每次都得先寫個(gè)php頁面嗎?
作者: 一劍橫天 時(shí)間: 2022-9-27 10:11
頁面比較多,因?yàn)槊總€(gè)頁面樣式不太一樣,所以沒打算用PHP寫,如果用html寫的話,每次都得先寫個(gè)php頁面嗎?
作者: 人工智能實(shí)驗(yàn)室 時(shí)間: 2022-9-27 10:27
是的,php文件調(diào)用模板
作者: 一劍橫天 時(shí)間: 2022-9-27 10:30
就是說不能html頁面調(diào)用模板的...
我要是想弄一個(gè)單頁的HTML頁面就得弄2個(gè)這個(gè)
作者: 科站網(wǎng) 時(shí)間: 2022-9-27 10:30
單頁制作教程 For Discuz!X2(DIY/左右邊欄/標(biāo)簽選項(xiàng)卡)
http://www.9999xn.com/thread-11144-1-1.html
(出處: Discuz!應(yīng)用商城(DisMall))
作者: 科站網(wǎng) 時(shí)間: 2022-9-27 10:32
多個(gè)你可以用PHP的參數(shù),比如這樣寫
- <?php
- require './source/class/class_core.php';
- $discuz = & discuz_core::instance();
- $discuz->init();
- $mod = $_GET['mod']
- if ($mod == 'shoye')
- {
- include template('wlk/shouye');
- }
- else{
- include template('wlk/qita');
- }
- ?>
復(fù)制代碼
作者: 科站網(wǎng) 時(shí)間: 2022-9-27 10:33
(, 下載次數(shù): 2)
- <?php
- require './source/class/class_core.php';
- $discuz = & discuz_core::instance();
- $discuz->init();
- $mod = $_GET['mod']
- if ($mod == 'a'){
- include template('test/a');
- }else{
- include template('test/b');
- }
- ?>
復(fù)制代碼
作者: 一劍橫天 時(shí)間: 2022-9-27 10:48
調(diào)用a、b倒是理解了,但是訪問的時(shí)候怎么判斷的呢?
比如訪問的是new.php,什么時(shí)候跳轉(zhuǎn)a什么時(shí)候跳轉(zhuǎn)b啊?
是new.php?a;new.php?b
這樣嗎?
作者: 一劍橫天 時(shí)間: 2022-9-27 11:02
按照這個(gè)寫,貌似沒法調(diào)用手機(jī)的模板?
作者: 科站網(wǎng) 時(shí)間: 2022-9-27 11:12
作者: 科站網(wǎng) 時(shí)間: 2022-9-27 11:13
手機(jī)版模版放置于template/模版目錄/touch
然后對應(yīng)PC的結(jié)構(gòu)
作者: 一劍橫天 時(shí)間: 2022-9-27 12:43
搞定了,非常感謝,不過現(xiàn)在最大的問題就是,我調(diào)用DZ的頭和底部,就是為了兼容DZ的一些插件,比如廣告插件,結(jié)果現(xiàn)在調(diào)用后這些插件都不正常展示
照理說,這些插件用得應(yīng)該是頭部和底部通用的嵌入點(diǎn)的
作者: 一劍橫天 時(shí)間: 2022-10-13 11:39
<?php
require './source/class/class_core.php';
$discuz = & discuz_core::instance();
$discuz->init();
$mod = $_GET['mod']
if ($mod == 'shoye')
{
include template('file:wlk/shouye');
}
else{
include template('file:wlk/qita');
}
?>
作者: 一劍橫天 時(shí)間: 2022-10-13 11:40
這個(gè)代碼報(bào)錯(cuò)了,蛋疼
作者: 一劍橫天 時(shí)間: 2022-10-13 11:49
后面這個(gè)代碼寫錯(cuò)了...不懂代碼的我來回折騰半天
作者: 湖中沉 時(shí)間: 2022-10-13 12:42
不是人家寫錯(cuò),是因?yàn)閒ile是編輯器IDE自動(dòng)加的類型識(shí)別提示,而非代碼本身
作者: 一劍橫天 時(shí)間: 2022-10-13 13:52
難怪,我用的VS,復(fù)制粘貼的他的代碼老是報(bào)錯(cuò),然后我把引號(hào)位置換了就正常了
歡迎光臨 Discuz! 官方交流社區(qū) (http://www.9999xn.com/) |
Powered by Discuz! W1.0 |