国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 網(wǎng)站 > 建站經(jīng)驗(yàn) > 正文

手把手教你制作織夢(mèng)自定義公告模板

2024-04-25 20:49:50
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
點(diǎn)評(píng):織夢(mèng)CMS很強(qiáng)大,用過(guò)的人驚嘆,織夢(mèng)開(kāi)發(fā)團(tuán)隊(duì)產(chǎn)品開(kāi)源后就已為我們?cè)O(shè)計(jì)了一套模板,看起來(lái)還不錯(cuò),但是用久了就發(fā)現(xiàn)很丑,很難看,并且也不是很完善,因此我們就有想自已DIY的想法。
 
 
比喻站點(diǎn)的最新公告顯示位就沒(méi)有,在網(wǎng)上找了好久,沒(méi)有發(fā)現(xiàn)相關(guān)的信息,可能是我沒(méi)有找到,所以就花了幾個(gè)小時(shí)研究了一下DEDECMS的部分源碼,試想,何不自已寫(xiě)呢 

好吧,想法有了,開(kāi)始形動(dòng)吧,跟我來(lái),讓狼人教你DIY一個(gè)自定義的模塊. 

在這里我就給大家舉一個(gè)實(shí)例<<站點(diǎn)公告信息的模板>> 

主要有:<<首頁(yè)顯示最新公告>>,<<公告詳細(xì)顯示頁(yè)面>>,<<公告列表頁(yè)面>> 

好的,我們一個(gè)個(gè)的來(lái) 


一.<<首頁(yè)顯示最新公告>>首先是在首頁(yè)顯示最新公告<在index.htm頁(yè)面添加代碼> 
代碼標(biāo)簽是:------------------------------------------------------------------------------ 

begin: 

{dede:mynews row='1' titlelen='20'}最新公告:[field:title /]<a href="show-mynews.php?aid=[field:aid /]">查看詳細(xì)</a></div>{/dede:mynews} 

end; 

=========================================================================================================================== 


二.<<公告詳細(xì)顯示頁(yè)面>>新建文件show-mynews.php 
代碼如下:------------------------------------------------------------------------------ 

begin: 

<?php 
require_once (dirname(__FILE__) . "/include/common.inc.php"); 
require_once DEDEINC."/arc.partview.class.php"; 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>公告詳細(xì)</title> 
<link href="/templets/style/dedecms.css" rel="stylesheet" media="screen" type="text/css" /> 
<script language="javascript" type="text/javascript" src="/include/dedeajax2.js"></script> 
<script src="/js/jquery-1.2.6.min.js" language="javascript" type="text/javascript"></script> 
</head> 
<body> 

<?php 
$pv = new PartView(); 
$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/default/head.htm"); 
$pv->Display(); 
?> 

<?php 
if (! is_numeric($aid)) 

echo "瀏覽頁(yè)面參數(shù)不正確"; 
exit; 

global $dsql; 
$row = $dsql->GetOne("Select * from dede_mynews where aid=$aid"); 
if(!is_array($row)) 

echo "對(duì)不起,沒(méi)有找到您所查找到的公告信息"; 
exit; 

?> 

<div class="w960 center" style="border:#ccc 1px solid;margin-top:5px;"> 
<?php 
echo "<h1 style='text-align:center;margin-top:20px;font-size:20px;border-bottom:#ccc 1px solid;'>".$row["title"]."</h1>"; 
echo "<div style='padding:8px;'>".$row["body"]."</div>"; 
?> 
</div> 

<?php 
$pv = new PartView(); 
$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/default/footer.htm"); 
$pv->Display(); 
?> 
</body> 
</html> 

end; 

=========================================================================================================================== 


三.<<公告列表頁(yè)面>>改顯示所有公告列表,不分頁(yè)<公告本來(lái)就不是很多所以這里我們不分頁(yè)顯示列表了>在include/taglib目錄下面找到文件(mynews.lib.php) 
代碼標(biāo)簽是:------------------------------------------------------------------------------ 

begin: 

<?php 
function lib_mynews(&$ctag,&$refObj) 

global $dsql,$envs; 
//屬性處理 
$attlist="row|1,titlelen|24"; 
FillAttsDefault($ctag->CAttribute->Items,$attlist); 
extract($ctag->CAttribute->Items, EXTR_SKIP); 

$innertext = trim($ctag->GetInnerText()); 
if(empty($row)) $row=1; 
if(empty($titlelen)) $titlelen=30; 
if(empty($innertext)) $innertext = GetSysTemplets('mynews.htm'); 

$idsql = ''; 
if($envs['typeid'] > 0) $idsql = " where typeid='".GetTopid($this->TypeID)."' "; 
$dsql->SetQuery("Select * from dede_mynews $idsql order by senddate desc limit 0,$row");

if($row == -1) $dsql->SetQuery("Select * from dede_mynews $idsql order by senddate desc");//狼人(QQ:459094521)加,如果設(shè)置為-1,就顯示所有文章 

$dsql->Execute(); 
$ctp = new DedeTagParse(); 
$ctp->SetNameSpace('field','[',']'); 
$ctp->LoadSource($innertext); 
$revalue = ''; 
while($row = $dsql->GetArray()) 

foreach($ctp->CTags as $tagid=>$ctag){ 
@$ctp->Assign($tagid,$row[$ctag->GetName()]); 

$revalue .= $ctp->GetResult(); 

return $revalue; 

?> 

end; 


在站點(diǎn)根目錄新建list-mynews.php里面寫(xiě)代碼: 

begin:/*用于調(diào)用/default/list-mynews.htm頁(yè)面的標(biāo)簽來(lái)顯示*/ 

<?php 
require_once (dirname(__FILE__) . "/include/common.inc.php"); 
require_once DEDEINC."/arc.partview.class.php"; 
$pv = new PartView(); 
$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/default/list-mynews.htm"); 
$pv->Display(); 
?> 

end; 

在templets/default目錄下面新建文件list-mynews.htm,并寫(xiě)代碼如下: 

begin: 

{dede:mynews row='-1' titlelen='20'}<br/> 
編號(hào):[field:aid /],<a href='show-mynews.php?aid=[field:aid /]'>標(biāo)題:[field:title /]</a>,作者:[field:writer /],發(fā)布時(shí)間:[field:senddate /],內(nèi)容:[field:body /]<br/> 
{/dede:mynews} 

end; 
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 图木舒克市| 金塔县| 焦作市| 凤山县| 徐水县| 饶平县| 天柱县| 巴东县| 应用必备| 丰宁| 锡林郭勒盟| 汝城县| 额敏县| 青阳县| 青阳县| 婺源县| 江永县| 连江县| 尼勒克县| 观塘区| 桂东县| 寿阳县| 娱乐| 惠水县| 方正县| 苍溪县| 东源县| 湘西| 根河市| 湘潭县| 鸡西市| 苍山县| 南充市| 子长县| 育儿| 连州市| 江阴市| 花莲县| 新邵县| 涿鹿县| 同德县|