PHPCMS中调用自定义BOX值与选项方法
2015-08-03 17:57
1036 查看
这几天在做调用一个自定义字段的BOX时需选项和值同时调用,现总结了以下方法分享给各位
<?php
$modelid=12;//模型ID
$field="changjing";//自定义字段名称
?>
<!-- 读取缓存-->
{php $modelid_cache = getcache('model_field_'.$modelid,'model');}
{php $data = explode("\r\n", $modelid_cache['changjing']['options']);}
{loop $data $r}
{php $r = explode("|",trim($r))}
{php $changjing_arr[$r[1]] = $r[0];}
{if $changjing == $r[1]}
<font style="color:#fff; background-color:#6633FF">{$r[0]}</font>
{else}
<li class="li2 hasUl2">
<h4 class="h2"><a class="a2" href="{$CATEGORYS[143][url]}&cat={$r[catid]}&yy={$r[1]}">{$r[0]}</a></h4></li>
{/if}
{/loop}
<?php
$modelid=12;//模型ID
$field="changjing";//自定义字段名称
?>
<!-- 读取缓存-->
{php $modelid_cache = getcache('model_field_'.$modelid,'model');}
{php $data = explode("\r\n", $modelid_cache['changjing']['options']);}
{loop $data $r}
{php $r = explode("|",trim($r))}
{php $changjing_arr[$r[1]] = $r[0];}
{if $changjing == $r[1]}
<font style="color:#fff; background-color:#6633FF">{$r[0]}</font>
{else}
<li class="li2 hasUl2">
<h4 class="h2"><a class="a2" href="{$CATEGORYS[143][url]}&cat={$r[catid]}&yy={$r[1]}">{$r[0]}</a></h4></li>
{/if}
{/loop}
相关文章推荐
- THINKPHP 数据库查询where语句条件
- php获得两个字符串公共最大子串的函数
- YII 数据库,模型,登录验证
- PHP禁止浏览器缓存
- PHP魔术方法之__call与__callStatic方法
- setlayoutparams报错
- PHP中try{}catch{}的具体用法详解
- Ubuntu 用vsftpd 配置FTP服务器
- PHP格式化输出打印变量
- Windows10中的IIS10安装php manager和IIS URL Rewrite 2.0组件的方法
- 在sublime text上直接运行php文件
- php中实现精确设置session过期时间的方法
- php构造函数连接数据库
- PHP-FPM之Chroot执行环境详解
- 在Windows命令行窗口中输入并运行PHP代码片段(不需要php文件)的方法
- PHP配置文件详解php.ini
- php ajax 实时显示时间
- (转)PHP中的ob_start用法详解
- php函数——『解析 xml数据』
- php生成图片验证码的实例讲解