DTcms 扩展字段标签调用
前台模版:
文章列表:{dr[author]}
文章内容{model.fields[author]} 点击数
后台CS文件:model.fields["author"].ToString()
赋值
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("good", "");
dic.Add("author", user.user_name);
model.fields = dic; //扩展字段赋值
#region 自定义:通过ID获取货号
protected string getGoods_No(int id)
{
string goods_no = "";
Model.article model = new BLL.article().GetModel(id);
List<Model.article_attribute_field> ls1 = new BLL.article_attribute_field().GetModelList(this.channel_id, "");
foreach (Model.article_attribute_field modelt1 in ls1)
{
if (modelt1.name == "goods_no")
{
if (model.fields["goods_no"] != null)
goods_no = model.fields["goods_no"].ToString();
}
} return goods_no;
} #endregion
#region 扩展字段赋值=============================
private Dictionary<string, string> SetFieldValues(int _channel_id)
{
DataTable dt = new BLL.article_attribute_field().GetList(_channel_id, "").Tables[];
Dictionary<string, string> dic = new Dictionary<string, string>();
foreach (DataRow dr in dt.Rows)
{
//查找相应的控件
switch (dr["control_type"].ToString())
{
case "single-text": //单行文本
TextBox txtControl = FindControl("field_control_" + dr["name"].ToString()) as TextBox;
if (txtControl != null)
{
dic.Add(dr["name"].ToString(), txtControl.Text.Trim()); }
break;
case "multi-text": //多行文本
goto case "single-text";
case "editor": //编辑器
HtmlTextArea htmlTextAreaControl = FindControl("field_control_" + dr["name"].ToString()) as HtmlTextArea;
if (htmlTextAreaControl != null)
{
dic.Add(dr["name"].ToString(), htmlTextAreaControl.Value);
}
break;
case "images": //图片上传
goto case "single-text";
case "video": //视频上传
goto case "single-text";
case "number": //数字
goto case "single-text";
case "datetime": //时间日期
goto case "single-text";
case "checkbox": //复选框
CheckBox cbControl = FindControl("field_control_" + dr["name"].ToString()) as CheckBox;
if (cbControl != null)
{
if (cbControl.Checked == true)
{
dic.Add(dr["name"].ToString(), "");
}
else
{
dic.Add(dr["name"].ToString(), "");
}
}
break;
case "multi-radio": //多项单选
RadioButtonList rblControl = FindControl("field_control_" + dr["name"].ToString()) as RadioButtonList;
if (rblControl != null)
{
dic.Add(dr["name"].ToString(), rblControl.SelectedValue);
}
break;
case "multi-checkbox": //多项多选
CheckBoxList cblControl = FindControl("field_control_" + dr["name"].ToString()) as CheckBoxList;
if (cblControl != null)
{
StringBuilder tempStr = new StringBuilder();
for (int i = ; i < cblControl.Items.Count; i++)
{
if (cblControl.Items[i].Selected)
{
tempStr.Append(cblControl.Items[i].Value.Replace(',', ',') + ",");
}
}
dic.Add(dr["name"].ToString(), Utils.DelLastComma(tempStr.ToString()));
}
break;
}
}
return dic;
}
#endregion
DTcms 扩展字段标签调用的更多相关文章
- 如何在调用Marketing Cloud contact创建API时增加对扩展字段的支持
需求:扩展字段"微信ID"是我创建出来的extension field,我想用Marketing Cloud提供的contact creation API,在创建contact时也 ...
- dedecms搜索模板,使用{dede:list}标签调用自定义字段不显示(空白)
前几天使用织梦做一个搜索功能,正常使用{dede:list}调用自定义内容模型中的自定义字段,代码如下:(自定义字段的调用可以参考:http://www.dede58.com/a/dedejq/523 ...
- DEDECMS标签调用汇总啊
非常有用的标签调用的方法 关键描述调用标签: <meta name="keywords" content="{dede:field name='keywords'/ ...
- 使用BAPI_ACC_DOCUMENT_POST,创建会计凭证,用BADI扩展字段(转)
业务需求:和银行做一个接口,要通过银行流水产生会计凭证,会计凭证的事务码是F-02,查到了BAPI方法BAPI_ACC_DOCUMENT_POST.昨天测试发现,有一些参数在BAPI_ACC_DOCU ...
- dede标签调用
关键描述调用标签: <meta name="keywords" content="{dede:field name='keywords'/}">&l ...
- 使用WCF扩展记录服务调用时间
随笔- 64 文章- 0 评论- 549 真实世界:使用WCF扩展记录服务调用时间 WCF 可扩展性 WCF 提供了许多扩展点供开发人员自定义运行时行为. WCF 在 Channel Lay ...
- 用Dedecms5.7的arclist标签调用文章内容
arclist标签调用文章内容 首先大家都知道在Dedecms中,list标签是可以调用文章内容的,调用格式就不再此冗述了.从我个人来说,我非常不喜欢用list标签调用,有可能我会尽量使用arclis ...
- dedecms利用memberlist标签调用自定义会员模型的会员信息
[摘要]本文讲一下dedecms如何利用memberlist标签调用自定义会员模型的会员信息. dedecms利用memberlist标签调用自定义会员模型的会员信息,这个问题找了很久,官方论坛提问过 ...
- golang自定义struct字段标签
原文链接: https://sosedoff.com/2016/07/16/golang-struct-tags.html struct是golang中最常使用的变量类型之一,几乎每个地方都有使用,从 ...
随机推荐
- C++中的inline函数
内联函数: () 内联函数定义和作用: 将一个函数声明为inline,那么函数就成为内联函数.内联函数通常就是它在程序中每个调用点上“内联地”展开.从定义上看,内联函数跟一般函数不一样,一般函数调用的 ...
- MYSQL SQL 审核工具 (inception安装步骤)
http://blog.csdn.net/wulantian/article/category/5825391
- php与ajax交互中文乱码(字符串转化)
一.从后台传过来的json不做处理,前端result.name这样调用回乱码.应该使用urldecode将jsonencod转码 注意json只接受utf-8编码的字符,所以json_encode() ...
- 新一代 PHP 加速插件 Zend Opcache
参考:http://www.laogui.com/Zend-Opcache 大家知道目前PHP的缓存插件一般有三个:APC.eAccelerator.XCache,但未来它们可能都会消失,因为PHP ...
- Helpers\Sessions
Helpers\Sessions The session is a static class, this means it can be used in any controller without ...
- 大文件读取方法(C#)
之前都是用StreamReader.ReadLine方法逐行读取文件,自从.NET4有了File.ReadLines这一利器,就再也不用为大文件发愁了. File.ReadLines在整个文件读取到内 ...
- 创建FILE GEODATABASE 和栅格目录及向栅格目录中添加影像
using System;using System.IO;using ESRI.ArcGIS.DataSourcesGDB;using ESRI.ArcGIS.DataSourcesRaster;us ...
- PHP代码加密 -- php_strip_whitespace函数,去掉源代码所有注释和空格并显示在一行
<?php function stripCommentAndWhitespace($path = '') { if (empty($path)) { echo '请指定要操作的文件路径'; re ...
- Netbackup磁带过期处理
bpexpdate -m <mediaid> -d 0 如果不通过,看是否被其他media server写入数据.使用 nbemmcmd -listhost 查看所有media serve ...
- Mirco2440核心板设计思考
1.核心板架构 注意的是:此处的RAM和ROM都是外置的 硬件框架 S3C2440+ SDRAM + NAND Flash + NOR Flash 也就是 CPU + RAM + ROM 2.S3C2 ...