Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

[已答复] ss中资讯中自定义字段如何调用?

[复制链接]
fishxk 发表于 2009-7-17 14:52:34 | 显示全部楼层 |阅读模式
本帖最后由 fishxk 于 2009-7-20 10:19 编辑

ss中资讯中自定义字段如何调用?
回复

使用道具 举报

littlehz 发表于 2009-7-17 15:43:17 | 显示全部楼层
参看默认模板的news_view.html.php
  1.           <!--{if !empty($news[custom][name])}-->
  2.           <div id="article_summary">
  3.             <!--{loop $news[custom][key] $ckey $cvalue}-->
  4.             <h6>$news[custom][name]</h6>
  5.             <p>$cvalue[name]:$news[custom][value][$ckey]</p>
  6.             <!--{/loop}-->
  7.           </div>
  8.           <!--{/if}-->
复制代码
回复

使用道具 举报

 楼主| fishxk 发表于 2009-7-17 16:31:51 | 显示全部楼层
问题是我现在不是在资讯模板里调用,在模型中调用,该如何写
回复

使用道具 举报

littlehz 发表于 2009-7-17 16:43:26 | 显示全部楼层
模型中调用资讯的自定义字段?模型怎么和资讯关联上?没有这个功能,只能写自定义SQL语句的模块查询数据表,然后还是用loop循环取数据。
回复

使用道具 举报

lidq.jingwu 发表于 2009-7-17 16:51:27 | 显示全部楼层
本帖最后由 lidq.jingwu 于 2009-7-21 08:46 编辑

SELECT i.*,n.*,c.type as c_type,c.name as c_name,c.displayorder as c_displayorder,c.customfieldtext as c_customfieldtext,c.isdefault as c_isdefault,c.isshare as c_isshare FROM supe_spaceitems i, supe_spacenews n, supe_customfields c WHERE i.itemid = n.itemid AND n.customfieldid = c.customfieldid AND n.customfieldid !=0
上面的一条SQL语句可以将你要的数据查出来,并显示在其他地方。
步骤:1、在后台以TAG为基本模块,创建一个模块,选中高级模式,将上面的SQL语句与你的数据库对照后放进去,设置下面的参数,保存,将产生JS或内部调用代码,就可以显示了。
回复

使用道具 举报

 楼主| fishxk 发表于 2009-7-20 10:16:27 | 显示全部楼层
感谢你的回复,那我如何调用出添加的字段数据
回复

使用道具 举报

 楼主| fishxk 发表于 2009-7-20 10:18:00 | 显示全部楼层
a:1:{i:0;a:3:{s:4:"type";s:6:"select";s:4:"name";s:3:"pmi";s:6:"option";s:8:"否
是";}}
回复

使用道具 举报

lwd815813 发表于 2009-7-31 18:50:58 | 显示全部楼层
我也想知道,如果在内容页面里只显示当前资讯信息的自定义字段应该怎么显示?默认模板的news_view.html.php只能在第一页显示,有什么可以做到其它分页都有?
回复

使用道具 举报

imjxx 发表于 2009-9-17 16:49:24 | 显示全部楼层
我也想知道
回复

使用道具 举报

lidq.jingwu 发表于 2009-9-17 17:50:12 | 显示全部楼层
如何查看资讯自定义字段:
有两种方法,一种是在资讯自己的模板(new_view.html.php)里面显示,这个数据在加载模板前已经放在$news这个变量里面了,在显示资讯内容的模板里面会看到这样的代码:
<!--{if !empty($news[custom][name])}-->
<div id="article_summary">
<!--{loop $news[custom][key] $ckey $cvalue}-->
<h6>$news[custom][name]</h6>
<p>$cvalue[name]news[custom][value][$ckey]</p>
<!--{/loop}-->
</div>
<!--{/if}-->
这一段代码就是将$news里面关于资讯自定义字段的内容取出来,并显示在页面上。

第二种方式是用SQL语句的来查询数据,SQL原型如下:
SELECT i.*,n.*,c.type as c_type,c.name as c_name,c.displayorder as c_displayorder,c.customfieldtext as c_customfieldtext,c.isdefault as c_isdefault,c.isshare as c_isshare FROM supe_spaceitems i, supe_spacenews n, supe_customfields c WHERE i.itemid = n.itemid AND n.customfieldid = c.customfieldid AND n.customfieldid !=0
通过supe_spaceitems,supe_spacenews,supe_customfields三表联查来取得数据,然后在模块功能里面用高级模式产生调用代码,展示代码如下:
<?exit?>
<!--{loop $_SBLOCK['c'] $value}-->
<!--{eval $c_name=unserialize($value[c_customfieldtext]);}-->
<!--{eval $custext=unserialize($value[customfieldtext]);}-->
<!--{if !empty($custext[0])}-->
<br>
<!--{eval $i=0;}-->
<!--{loop $custext $cvalue}-->
<!--{echo $c_name[$i][name]}-->:<!--{echo $cvalue}-->
<!--{eval $i=$i+1;}-->
<!--{/loop}-->
<!--{/if}-->
<!--{/loop}-->
此展示代码对应的是本机的变量,如果用,要做修改,并添加CSS。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-9-14 05:56 , Processed in 0.138822 second(s), 14 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表