织梦CMS仿站:幻灯片的后台调用

织梦幻灯片调用:频道模型
自定义模型
目的:解决现有模型无法满足现有需求
一、后台的使用
1.新建模型
核心--频道管理--内容模型管理

2.点击新增新模型

3.新建模型设置如下

4. 点击字段管理增加模型字段

5. 栏目模型更改为新建的模型

6. 在该栏目下增加内容

7. 出现模板文件不存在,无法解析文档!解决方法
(1)不需要理会
应为该栏目不需要生成内容页文档
(2)看着不好看,强迫症患者
点击修改栏目----高级选项----查模板名称


在模板目录里新建箭头的指向的三个文件即可解决。
二、前台的调用
1.打开 /include/extend.func.php 在最下面添加(只修改一次就可以)




if(!function_exists('GetImgUrl'))
{
function GetImgUrl($fieldname, $ftype = 1)
{
if($fieldname != '')
{
$dtp = new DedeTagParse();
$dtp->LoadSource($fieldname);
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 .= '<img src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" />';
}
}
}
}
}
$dtp->Clear();
return $img;
}
}
}

2. 打开织梦标签生成器

复制生成的代码
{dede:arclist typeid=50 row=5 orderby='pubdate'}
<li><a href="[field:arcurl/]">[field:title/]</a></li>
{/dede:arclist}
将第一行增加标黄地方的参数
{dede:arclist typeid='1' row='14' titlelen='50' channelid='模型id号' addfields='自定义字段1,自定义字段2,....'}
其中模型id在 核心--频道模型--内容模型管理---id号

调用普通字段分方法
[field:自定义图片字段名/]
调用图片字段方法
[field:自定义图片字段名 function=GetImgUrl(@me)/]
整体代码如下:



{dede:arclist typeid=50 row=5 orderby='pubdate' channelid='模型id号' addfields='自定义字段1,自定义字段2,....'}
[field:自定义图片字段名/]
[field:自定义图片字段名 function=GetImgUrl(@me)/]
{/dede:arclist}

3.找到幻灯片相应的代码区域进行替换(以商务学院官网为例)

举报
评论 0