太阳成游戏网站

联系官方销售客服

QQ1835022299

028-61286886

POSCMS 版主:POSCMS负责人
diy\poscms\field\Related.php关联
类型:POSCMS 更新时间:2019-06-26 14:47:16 php

diy\poscms\field\Related.php

关联内容时候只显示标题,希望改成同时显示缩略图。

image.png


发布和编辑时候显示效果如下(红色标记为图):

image.png




回帖
  • 资阳胖子
    #1楼    资阳胖子
    2019-06-26 07:23:52
    0
  • 晕菜菜
    #2楼    晕菜菜
    2019-06-26 08:43:20
    0
    不可以哦!核心文件不可以这么写的资阳胖子
  • 悲剧的石头
    #3楼    悲剧的石头
    2019-06-26 09:25:32
    0
    代码不要截图
  • 晕菜菜
    #4楼    晕菜菜
    2019-06-26 10:41:41
    0
    悲剧的石头/** * POSCMS框架文件 * 二次开发时请勿修改本文件 * 成都天睿信息技术有限公司 www.phpkaiyuancms.com */class F_Related extends A_Field { /** * 构造函数 */ public function __construct() { parent::__construct(); $this->name = fc_lang('内容关联'); // 字段名称 $this->fieldtype = array('TEXT' => ''); // TRUE表全部可用字段类型,自定义格式为 array('可用字段类型名称' => '默认长度', ... ) $this->defaulttype = 'TEXT'; // 当用户没有选择字段类型时的缺省值 } /** * 字段相关属性参数 * * @param array $value * @return string */ public function option($option) { $_option = ''; $_module = $this->ci->get_cache('module', SITE_ID); if ($_module) { foreach ($_module as $dir) { $_option.= ''; } } $option['width'] = isset($option['width']) ? $option['width'] : '90%'; return '
    '.fc_lang('必须选择一个模块作为关联数据源').'
    '.fc_lang('[整数]表示固定宽带;[整数%]表示百分比').'
    '.fc_lang('关联列表搜索结果最大显示数量,默认50条').'
    '.fc_lang('此字段不能参与搜索条件筛选').'
    ';
    } /** * 字段输出 */ public function output($value) { return $value; } /** * 字段入库值 */ public function insert_value($field) { $data = $this->ci->post[$field['fieldname']]; $value = !$data ? '' : implode(',', $data); $this->ci->data[$field['ismain']][$field['fieldname']] = $value; } /** * 字段表单输入 * * @param string $cname 字段别名 * @param string $name 字段名称 * @param array $cfg 字段配置 * @param string $value * @return string */ public function input($cname, $name, $cfg, $value = NULL, $id = 0) { // 字段显示名称 $text = (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1 ? '*' : '').''.$cname.':'; // 表单宽度设置 $width = isset($cfg['option']['width']) && $cfg['option']['width'] ? $cfg['option']['width'] : '80%'; // 表单附加参数 $attr = isset($cfg['validate']['formattr']) && $cfg['validate']['formattr'] ? $cfg['validate']['formattr'] : ''; // 字段提示信息 $tips = isset($cfg['validate']['tips']) && $cfg['validate']['tips'] ? ''.$cfg['validate']['tips'].'' : ''; // 禁止修改 $disabled = !IS_ADMIN && $id && $value && isset($cfg['validate']['isedit']) && $cfg['validate']['isedit'] ? 'disabled' : ''; // 模块名称 $module = isset($cfg['option']['module']) ? $cfg['option']['module'] : ''; // $tpl = '
  •  {value}
  • '; // $str = '
    '; $str.= ''.$cname.''; $str.= '
    '; $str.= '
      '; $value = @trim($value, ','); if ($value && is_string($value)) { $query = $this->ci->db->query('select id,title,url,thumb from '.$this->ci->db->dbprefix(SITE_ID.'_'.$module).' where id IN ('.$value.') order by instr("'.$value.'", id)')->result_array(); foreach ($query as $t) { $id = $t['id']; $value = ''.$t['thumb'].''; $str.= str_replace(array('{id}', '{value}'), array($id, $value), $tpl); } } $str.= '
    ';
    $str.= '
    ';
    $str.= '
    ';
    if(!defined('FINECMS_LINKAGE_INIT_LD')) { define('FINECMS_LINKAGE_INIT_LD', 1); $str.= ''; } $str.= '
    ';
    $str.= '
    ';
    $str.= ''; $str.= $tips; return $this->input_format($name, $text, $str); }}文件路径:diy\poscms\field\Related.php
  • skyep
    #5楼    skyep
    2019-06-26 14:09:15
    0

    $value = ''.$t['thumb'].'';

    $str.= str_replace(array('{id}', '{value}'), array($id, $value), $tpl);
    改成

    $value = ''.$t['title'].'';

    $str.= str_replace(array('{id}', '{value}'), array($id, $value), $tpl);

  • 晕菜菜
    #6楼    晕菜菜
    2019-06-26 14:12:11
    0
    skyep
    image.png
    这个不对哦!显示是数字呢!
  • 晕菜菜
    #7楼    晕菜菜
    2019-06-26 14:13:08
    0
    skyep路径没有问题,就是这个屌毛数字怎么转换成文件名!
  • Mark
    #8楼    Mark
    2019-06-26 14:33:02
    0
    你不是单文件吗?
  • 农村人
    #9楼    农村人
    2019-06-26 14:35:41
    0

    $img = dr_string2array($t['thumb']); // 图片专用字段

    $value = ''.$t['title'].'';

    $str.= str_replace(array('{id}', '{value}'), array($id, $value), $tpl);

    满意答案
  • 晕菜菜
    #10楼    晕菜菜
    2019-06-26 14:47:16
    0
    @农村人:跪谢大神~谢谢啦~
  • 相关问题