首页 > CMS > PhpCMS > 正文

PHPCMS模板中$forminfos循环输出表单的代码详解

2024-07-09 22:54:17
字体:
来源:转载
供稿:网友
phpcms中后台模型管理处设置模型定段后,内容发布处和信息管理发布处自动循环输出各字段,生成表单,代码如下:

<table cellpadding="0" cellspacing="1" class="table_form"> 
    <caption>修改信息</caption> 
    {loop $forminfos $field $info}  
    <tr>   
      <th width="20%">{if $info['star']} <font color="red">*</font>{/if} <strong>{$info[name]}</strong><br /> 
      {$info[tips]}  
      </th> 
      <td>{$info[form]} </td> 
    </tr> 
    {/loop}  
    <tr>   
      <td></td> 
      <td>   
      <input type="hidden" name="forward" value="{$forward}">   
      <input type="submit" name="dosubmit" value=" 确定 ">   
      <input type="reset" name="reset" value=" 清除 "> 
      <input type="button" name="preview" value=" 预览 " onclick="preview_content();"> 
      </td> 
    </tr> 
</table> 
</form> 

$info[form]是调用的哪里的内容,是引用该模板的对应PHP文件中将PHPCMS模型各字段内容读取记入$forminfos数组,然后在PHPCMS模板中通过loop循环标签输出,每一项都包含 {$info[name]},{$info[form]},{$info[tips]}等几项。

{$info[name]}:输出字段名,如“标题”
{$info[form]}:输出该字段的模型,如可能是input表单字段,可能是radio选项字段,也可能是图片上传或内容编辑器等
{$info[tips]}则为字段提示
注:相关教程知识阅读请移步到PHPCMS教程频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表