logo

(PHP)JTBC1.0图片集任意位置调用实现方法

2025-02-19 点击 72
1.添加格式化函数

//说明,共3个参数,第一个为图片集字符串,第二个为模块名,第三个为输出样式(默认为下拉框,可选img,为图片,具体样式可修改节点)

function mm_get_images_list($strers,$genre='',$type='')
{
  if (!(ii_isnull($strers)))
  {
    $option_unselected = ii_itake('global.tpl_config.option_unselect', 'tpl');
    if($type=='img') $option_unselected = ii_itake('global.tpl_config.images_list', 'tpl');
    $tary = explode('|', $strers);
    $tmpstr = '';
    foreach ($tary as $key => $val)
    {
      $tstr = $option_unselected;
      $tstr = str_replace('{$explain}', $val, $tstr);
      $tstr = ($genre!='') ?str_replace('{$value}', $genre.'/'.$val, $tstr): str_replace('{$value}', $val, $tstr);
      $tmpstr .= $tstr;
    }
    return $tmpstr;
  }
}
2.添加节点global.tpl_config.images_list
下拉框节点(如存在不用加)
    <item>
      <name><![CDATA[xmlselect_unselect]]></name>
      <tpl_default><![CDATA[<option value="{$value}">{$explain}</option>]]></tpl_default>
    </item>
    
    
图片节点

    <item>
      <name><![CDATA[images_list]]></name>
      <tpl_default><![CDATA[<img src="{$value}">]]></tpl_default>
    </item>

3.调用模板
ab_imglist

{@}
{$content_images_list}
{@}

4.调用方法


{$=mm_get_images_list(vv_itransfer('all', 'ab_imglist', 'topx=1;tnum=30;genre=aboutus;osql= and abid=1'),'aboutus','img')}

0%