wangwangwa 发表于 2013-8-10 16:43:08

织梦DEDECMS网站内容模型普通文章调用自定义图片字段的方法


   

   



         .Dym857 { display:none; }
织梦DedeCMS网站内容模型普通文章调用自定义图片字段的方法:

我们首先需要创建一个自定义函数, copyright
找到:/include/extend.func.php ,在 ''){   
               $dtp = new DedeTagParse();   
               $dtp->LoadSource($img);   
               if(is_array($dtp->CTags)){   
                   foreach($dtp->CTags as $ctag){   
                     if($ctag->GetName()=='img'){   
                           $width = $ctag->GetAtt('width');   
                           $height = $ctag->GetAtt('height');   
                           $imgurl = trim($ctag->GetInnerText());   
                           $img = '';   
                           if($imgurl != ''){   
                               if($ftype==1){   
                                 $img .= $imgurl;   
                               }   
                               else{   
                                 $img .= '';   
                               }   
                           }   
                                                      }   
   
                                    
                                                  

   

   



         .Hry746 { display:none; }
               }   
               }   
               $dtp->Clear();   
               return $img;   
               }   
       }


这个自定义函数使用dedecms标签调用方法 DEDECMS模板


   


比如:我们的自定义图片字段名为 imgurl ,那么调用方式有以下两种: DEDE模板


    标签)–>   
       


模型字段添加
DEDECMS模板
[核心]——[内容模型管理],点击“普通文章”的“更改”按钮,进入编辑界面,切换到“字段管理”选项,点击“添加新字段” copyright



创建好字段以后,我们在增加或编辑文档时候,就会有这个添加的自定义图片字段了。
在前台调用我们可以使用下面的标签 copyright
大体的自定义字段的方法是这样的: DEDE模板


    {dede:arclist row=’2′ channeld=’1′ addfields=’自定义字段1,自定义字段2′}   
    底层模板   
    {/dede:arclist}


运用到我们刚才的这个函数,调用方法为:



    {dede:arclist row='6' orderby='id' channelid='1' addfields='itpic2'}   {/dede:arclist}
    {dede:arclist row='3' orderby=click type='image.' typeid='3' titlelen='28' addfields='litpic2' channelid='1'}
          ' width='180' height='280' border='0' alt='
    {/dede:arclist}



这个标签还是蛮有用的。需要记住了哦!
页: [1]
查看完整版本: 织梦DEDECMS网站内容模型普通文章调用自定义图片字段的方法