文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>让field:title 标题突破30这个长度,修改代码的方法

让field:title 标题突破30这个长度,修改代码的方法

时间:2006-09-20  来源:w3g8

找到./include/inc_arcpart_view.php
行291 :
if($titlelen=="") $titlelen = 30;
修改为
if($titlelen=="") $titlelen = 60;
就可以了,然后,你可以这样调用了
    {dede:channelArtlist typeid='0' col=1 tablewidth='100%'}
                      {dede:arclist row="10"}
                    [field:title function="cn_substr('@me',38)" /]
                          
                    {/dede:arclist}
      {/dede:channelArtlist}
把这个延伸一下:关于inc_arcpart_view.php
function GetArcList($typeid=0,$row=10,$col=1,$titlelen=30,$infolen=160,
$imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$keyword="",
$innertext="",$tablewidth="100",$arcid=0,$idlist="")
这里的参数都可以更改你实际需要的模板元素尺寸大小.


LZ要注意一个情况,dedecms那些解析模板的函数几乎都可以用属性表示的,看一下这里
CODE:
else if($tagname=="arclist"||$tagname=="artlist"||$tagname=="likeart"||$tagname=="hotart"
            ||$tagname=="imglist"||$tagname=="imginfolist"||$tagname=="coolart"||$tagname=="specart")
           {
                //特定的文章列表
                $channelid = $ctag->GetAtt("channelid");
                if($tagname=="imglist"||$tagname=="imginfolist"){ $listtype = "image"; }
                else if($tagname=="specart"){ $channelid = -1; }
                else if($tagname=="coolart"){ $listtype = "commend"; }
                else{ $listtype = $ctag->GetAtt('type'); }
               
                //排序
                if($ctag->GetAtt('sort')!="") $orderby = $ctag->GetAtt('sort');
                else if($tagname=="hotart") $orderby = "click";
                else $orderby = $ctag->GetAtt('orderby');
               
                //对相应的标记使用不同的默认innertext
                if(trim($ctag->GetInnerText())!="") $innertext = $ctag->GetInnerText();
                else if($tagname=="imglist") $innertext = GetSysTemplets("part_imglist.htm");
                else if($tagname=="imginfolist") $innertext = GetSysTemplets("part_imginfolist.htm");
                else $innertext = GetSysTemplets("part_arclist.htm");
               
                //兼容titlelength
                if($ctag->GetAtt('titlelength')!="") $titlelen = $ctag->GetAtt('titlelength');
                else $titlelen = $ctag->GetAtt('titlelen');
               
                //兼容infolength
                if($ctag->GetAtt('infolength')!="") $infolen = $ctag->GetAtt('infolength');
                else $infolen = $ctag->GetAtt('infolen');
               
                //类别ID
                if(trim($ctag->GetAtt('typeid'))=="" && $this->TypeID!=0){ $typeid = $this->TypeID; }
                else{ $typeid = trim( $ctag->GetAtt('typeid') ); }
               
                $this->dtp->Assign($tagid,
                    $this->GetArcList($typeid,
                      $ctag->GetAtt("row"),
                      $ctag->GetAtt("col"),
                      $titlelen,
                      $infolen,
                      $ctag->GetAtt("imgwidth"),
                      $ctag->GetAtt("imgheight"),
                      $ctag->GetAtt("type"),
                      $orderby,
                      $ctag->GetAtt("keyword"),
                      $innertext,
                      $ctag->GetAtt("tablewidth"),
                      0,
                      "",
                      $channelid,
                      $ctag->GetAtt("limit")
                    )
                );
           }
[url=javascript:][Copy to clipboard][/url]
关于标题长度的问题,有些人是希望超过30个中文,即是 60以外,这样的话恐怕只能更改数据库里的字段,和更改内容发布程序

谢谢itprato的回复,
上次在落伍你提醒了我,我也按照你的思路去看了一下,数据库里的title字段,和发布程序里的title标签,他们都有个60的限制,超过60就要改这些长度了。
我在改title的时候也修改了数据库结构,title的长度,这个在忘了贴出。dedecms 的思想还正在理解中。

./include/inc_arcpart_view.php
282行:
function GetArcList($typeid=0,$row=10,$col=1,$titlelen=30,$infolen=160,
$imgwidth=120,$imgheight=90,$listtype="all",$orderby="default",$keyword="",
$innertext="",$tablewidth="100",$arcid=0,$idlist="")
这里的$titlen=30是否已经定死了,没法超过30了
//兼容titlelength
          if($ctag->GetAtt('titlelength')!="") $titlelen = $ctag->GetAtt('titlelength');
          else $titlelen = $ctag->GetAtt('titlelen');
不能发挥这段代码的作用。
刚才发了这个,自己都郁闷,哪个$titlen=30只是个默认值,怎么可能定死了,呵呵,理解错了
else if($tagname=="arclist"||$tagname=="artlist"||$tagname=="likeart"||$tagname=="hotart"
        ||$tagname=="imglist"||$tagname=="imginfolist"||$tagname=="coolart"||$tagname=="specart")
这里的兼容前提的条件是$tagname == arclist,
而这里的代码:
      {dede:channelArtlist typeid='0' col=1 tablewidth='100%'}
      {/dede:channelArtlist}
$tagname == "channelArtlist"
好象解析模板的时候,检查这里就不检查包含在里面的
{dede:arclist row="10"}
{/dede:arclist}中的$tagname == arclist,
就是说,这里的
if($tagname=="arclist"|| 由于前面的{dede:channelArtlist 没其到兼容的作用,
我为了证实这个想法,把
{dede:channelArtlist typeid='0' col=1 tablewidth='100%'}
      {/dede:channelArtlist}
去掉了,后来就可以这样写了
{dede:arclist titlelength='60' row="8"}
{/dede:arclist}
后面加个titlelength 的长度限制就可以了,这样就可以超过原先的15个汉字。
我也遇到了这个问题。我和楼主一样。想的也是直接去修改原文件来达到自己需要的目的。
来论坛一搜。呵呵。看到了这个帖子。。茅塞顿开。。DEDE真是太灵活了。
修正楼主一点小错误。
{dede:arclist titlelen='60' row="8"}
{/dede:arclist}
是这样的。   
楼主的这个
{dede:arclist titlelength='60' row="8"}
{/dede:arclist}
是错误的。
测试可用。
我是修改主页调用版块文章。遇到这个问题的。
{dede:arclist titlelen='42' row="8"} ·[field:title /]
{/dede:arclist}   
就是这个。。
已经好了。可以用了。








相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载