織夢二次開發增加一個或多個欄目的欄目內容


 在二次開發的時,我們有時需要對 織夢的欄目內容進行添加,如下圖。



怎么樣,我一下子增加了5個,是否威武哈。
某些情況下需要這么多滴,這個時候頻道頁就可以做很多效果了,比如Tabs切換效果。 
現在開始發布修改方法:

首先要再數據庫中添加相應的字段

SQL語句  
ALTER TABLE `你的數據庫表前綴_arctype` ADD `content1` TEXT NOT NULL AFTER `content` ;

如果只增加一次的話就運行一次就可以了,如果增加多個的話就繼續運行,但是要注意添加的字段名,我懶的起名,起的字段名加數字,


ALTER TABLE `你的數據庫表前綴_arctype` ADD `content2` TEXT NOT NULL AFTER `content1` ;

ALTER TABLE `你的數據庫表前綴_arctype` ADD `content3` TEXT NOT NULL AFTER `content2` ;

ALTER TABLE `你的數據庫表前綴_arctype` ADD `content4` TEXT NOT NULL AFTER `content3` ;

ALTER TABLE `你的數據庫表前綴_arctype` ADD `content5` TEXT NOT NULL AFTER `content4` ;
......




第二步  dede\catalog_edit.php

在      `content`='$content', 下 增加

  `content1`='$content1',
  `content2`='$content2',
  `content3`='$content3',
  `content4`='$content4',
  `content5`='$content5',

這里是保存數據用的。




第三步是最繁瑣的,也是最容易出錯的,

dede\templets\catalog_edit.htm


修改  

<table width="100%" border="0" cellspacing="0" id="head1" cellpadding="0">
          <tr> 
            <td colspan="2" bgcolor="#FFFFFF" align="left">
           <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="84" height="24" align="center" background="images/itemnote1.gif"> 常規選項 </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem2()"><u>高級選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem3()"><u>欄目內容</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem4()"><u>附加內容1</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem5()"><u>附加內容2</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem7()"><u>附加內容3</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem8()"><u>附加內容4</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem9()"><u>附加內容5</u>< /a> </td>
                </tr>
              </table>
            </td>
          </tr>
        </table> 


紅色是新增加的代碼 由於有多個,而且重復,也只是輕微的變化,我直接貼出全部的代碼部分

<table width="100%" border="0" cellspacing="0" id="head1" cellpadding="0">
          <tr> 
            <td colspan="2" bgcolor="#FFFFFF" align="left">
           <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="84" height="24" align="center" background="images/itemnote1.gif"> 常規選項 </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem2()"><u>高級選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem3()"><u>欄目內容</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem4()"><u>附加內容1</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem5()"><u>附加內容2</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem7()"><u>附加內容3</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem8()"><u>附加內容4</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem9()"><u>附加內容5</u>< /a> </td>
                </tr>
              </table>
            </td>
          </tr>
        </table> 
        
        <table width="100%" border="0" cellspacing="0" id="head2" cellpadding="0" style="display:none">
          <tr>
            <td colspan="2" bgcolor="#FFFFFF"  style="text-align:left;">
          <table height="24" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="84" align="center" background="images/itemnote2.gif" bgcolor="#F2F7DF"& gt;<a href="#" onClick="ShowItem1()"><u>常規選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote1.gif"> 高級選項 </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem3()"><u>欄目內容</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem4()"><u>附加內容1</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem5()"><u>附加內容2</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem7()"><u>附加內容3</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem8()"><u>附加內容4</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem9()"><u>附加內容5</u>< /a> </td>
                </tr>
              </table>
            </td>
          </tr>
       </table>
       
       <table width="100%" border="0" cellspacing="0" id="head3" cellpadding="0" style="display:none">
          <tr>
            <td colspan="2" bgcolor="#FFFFFF" style="text-align:left;">
             <table height="24" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="84" align="center" background="images/itemnote2.gif" bgcolor="#F2F7DF"& gt;<a href="#" onClick="ShowItem1()"><u>常規選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem2()"><u>高級選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote1.gif"> 欄目內容 </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem4()"><u>附加內容1</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem5()"><u>附加內容2</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem6()"><u>附加內容3</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem7()"><u>附加內容4</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem8()"><u>附加內容5</u>< /a> </td>
                </tr>
              </table>
            </td>
          </tr>
       </table>
    
    <table width="100%" border="0" cellspacing="0" id="head4" cellpadding="0" style="display:none">
          <tr>
            <td colspan="2" bgcolor="#FFFFFF" style="text-align:left;">
             <table height="24" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="84" align="center" background="images/itemnote2.gif" bgcolor="#F2F7DF"& gt;<a href="#" onClick="ShowItem1()"><u>常規選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem2()"><u>高級選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem3()"><u>欄目內容</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote1.gif"> 附加內容1 </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem5()"><u>附加內容2</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem6()"><u>附加內容3</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem7()"><u>附加內容4</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem8()"><u>附加內容5</u>< /a> </td>
                </tr>
              </table>
            </td>
          </tr>
       </table>
    
    <table width="100%" border="0" cellspacing="0" id="head5" cellpadding="0" style="display:none">
          <tr>
            <td colspan="2" bgcolor="#FFFFFF" style="text-align:left;">
             <table height="24" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="84" align="center" background="images/itemnote2.gif" bgcolor="#F2F7DF"& gt;<a href="#" onClick="ShowItem1()"><u>常規選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem2()"><u>高級選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem3()"><u>欄目內容</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem4()"><u>附加內容1</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote1.gif"> 附加內容2 </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem6()"><u>附加內容3</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem7()"><u>附加內容4</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem8()"><u>附加內容5</u>< /a> </td>
                </tr>
              </table>
            </td>
          </tr>
       </table>
    
    <table width="100%" border="0" cellspacing="0" id="head6" cellpadding="0" style="display:none">
          <tr>
            <td colspan="2" bgcolor="#FFFFFF" style="text-align:left;">
             <table height="24" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="84" align="center" background="images/itemnote2.gif" bgcolor="#F2F7DF"& gt;<a href="#" onClick="ShowItem1()"><u>常規選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem2()"><u>高級選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem3()"><u>欄目內容</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem4()"><u>附加內容1</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem5()"><u>附加內容2</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote1.gif">附加內容3 </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem7()"><u>附加內容4</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem8()"><u>附加內容5</u>< /a> </td>
                </tr>
              </table>
            </td>
          </tr>
       </table>
    
    
     <table width="100%" border="0" cellspacing="0" id="head7" cellpadding="0" style="display:none">
          <tr>
            <td colspan="2" bgcolor="#FFFFFF" style="text-align:left;">
             <table height="24" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="84" align="center" background="images/itemnote2.gif" bgcolor="#F2F7DF"& gt;<a href="#" onClick="ShowItem1()"><u>常規選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem2()"><u>高級選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem3()"><u>欄目內容</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem4()"><u>附加內容1</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem5()"><u>附加內容2</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem6()"><u>附加內容3</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote1.gif">附加內容4 </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem8()"><u>附加內容5</u>< /a> </td>
                </tr>
              </table>
            </td>
          </tr>
       </table>
    
    <table width="100%" border="0" cellspacing="0" id="head8" cellpadding="0" style="display:none">
          <tr>
            <td colspan="2" bgcolor="#FFFFFF" style="text-align:left;">
             <table height="24" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="84" align="center" background="images/itemnote2.gif" bgcolor="#F2F7DF"& gt;<a href="#" onClick="ShowItem1()"><u>常規選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem2()"><u>高級選項</u>< /a> </td>
                  <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem3()"><u>欄目內容</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem4()"><u>附加內容1</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem5()"><u>附加內容2</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem6()"><u>附加內容3</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote2.gif"& gt;<a href="#" onClick="ShowItem7()"><u>附加內容4</u>< /a> </td>
      <td width="84" align="center" background="images/itemnote1.gif">附加內容5 </td>
                </tr>
              </table>
            </td>
          </tr>
       </table>


以上只是切換標題部分,現在我們來修改切換的內容部分




我直接貼出了內容部分,照着增加就是

<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #cfcfcf;background:#ffffff;display:none;text-align:left;" id="ctset">
<tr> 
<td height="28"> 說明:欄目內容是替代原來欄目單獨頁的更靈活的一種方式,可在欄目模板中用{dede:field.content/}調用,通常用於企業簡介之類的用途。</td>
</tr>
<tr> 
<td style="padding:10px;">
<?php
GetEditor("content",$myrow['content'],"450","Default","print","false");
?> 
</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #cfcfcf;background:#ffffff;display:none;text-align:left;" id="ctset1">
<tr> 
<td height="28"> 說明:附加1111111111111欄目內容是替代原來欄目單獨頁的更靈活的一種方式,可在欄目模板中用{dede:field.content/}調用,通常用於企業簡介之類的用途。</td>
</tr>
<tr> 
<td style="padding:10px;">
<?php
GetEditor("content1",$myrow['content1'],"450","Default","print","false");
?> 
</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #cfcfcf;background:#ffffff;display:none;text-align:left;" id="ctset2">
<tr> 
<td height="28"> 說明:附加1222222222221欄目內容是替代原來欄目單獨頁的更靈活的一種方式,可在欄目模板中用{dede:field.content/}調用,通常用於企業簡介之類的用途。</td>
</tr>
<tr> 
<td style="padding:10px;">
<?php
GetEditor("content2",$myrow['content2'],"450","Default","print","false");
?> 
</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #cfcfcf;background:#ffffff;display:none;text-align:left;" id="ctset3">
<tr> 
<td height="28"> 說明:附加33333333欄目內容是替代原來欄目單獨頁的更靈活的一種方式,可在欄目模板中用{dede:field.content/}調用,通常用於企業簡介之類的用途。</td>
</tr>
<tr> 
<td style="padding:10px;">
<?php
GetEditor("content3",$myrow['content3'],"450","Default","print","false");
?> 
</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #cfcfcf;background:#ffffff;display:none;text-align:left;" id="ctset4">
<tr> 
<td height="28"> 說明:附加44444444444411欄目內容是替代原來欄目單獨頁的更靈活的一種方式,可在欄目模板中用{dede:field.content/}調用,通常用於企業簡介之類的用途。</td>
</tr>
<tr> 
<td style="padding:10px;">
<?php
GetEditor("content4",$myrow['content4'],"450","Default","print","false");
?> 
</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #cfcfcf;background:#ffffff;display:none;text-align:left;" id="ctset5">
<tr> 
<td height="28"> 說明:附加15555555111欄目內容是替代原來欄目單獨頁的更靈活的一種方式,可在欄目模板中用{dede:field.content/}調用,通常用於企業簡介之類的用途。</td>
</tr>
<tr> 
<td style="padding:10px;">
<?php
GetEditor("content5",$myrow['content5'],"450","Default","print","false");
?> 
</td>
</tr>
</table>



最后是JS部分 

這里也挺繁瑣,只是注意就行了,也沒難度。
[quote]function ShowItem1(){
ShowObj('head1'); ShowObj('needset');
HideObj('head2'); HideObj('adset');
HideObj('head3'); HideObj('ctset');
HideObj('head4'); HideObj('ctset1');
HideObj('head5'); HideObj('ctset2');
HideObj('head6'); HideObj('ctset3');
HideObj('head7'); HideObj('ctset4');
HideObj('head8'); HideObj('ctset5');
}

function ShowItem2(){
HideObj('head1'); HideObj('needset');
ShowObj('head2'); ShowObj('adset');
HideObj('head3'); HideObj('ctset');
HideObj('head4'); HideObj('ctset1');
HideObj('head5'); HideObj('ctset2');
HideObj('head6'); HideObj('ctset3');
HideObj('head7'); HideObj('ctset4');
HideObj('head8'); HideObj('ctset5');
}
function ShowItem3(){
HideObj('head1'); HideObj('needset');
HideObj('head2'); HideObj('adset');
ShowObj('head3'); ShowObj('ctset');
HideObj('head4'); HideObj('ctset1');
HideObj('head5'); HideObj('ctset2');
HideObj('head6'); HideObj('ctset3');
HideObj('head7'); HideObj('ctset4');
HideObj('head8'); HideObj('ctset5');
}
function ShowItem4(){
HideObj('head1'); HideObj('needset');
HideObj('head2'); HideObj('adset');
HideObj('head3'); HideObj('ctset');
ShowObj('head4'); ShowObj('ctset1');
HideObj('head5'); HideObj('ctset2');
HideObj('head6'); HideObj('ctset3');
HideObj('head7'); HideObj('ctset4');
HideObj('head8'); HideObj('ctset5');
}
function ShowItem5(){
HideObj('head1'); HideObj('needset');
HideObj('head2'); HideObj('adset');
HideObj('head3'); HideObj('ctset');
HideObj('head4'); HideObj('ctset1');
ShowObj('head5'); ShowObj('ctset2');
HideObj('head6'); HideObj('ctset3');

至此就修改好了。 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM