1,找到ParserController.php,添加代码
路径:\apps\home\controller\ParserController.php
作用:该文件的作用之一,便是识别标签代码,如:“[list:title]”
修改:大约在3580行,注释为“// 解析列表标签”的方法里,添加新的case。
原代码:
case 'subsortname': if ($data->subsortname) { $content = str_replace($search, $this->adjustLabelData($params, $data->subsortname, $label), $content); } else { $content = str_replace($search, '', $content); } break;
添加新代码后:
case 'subsortname': if ($data->subsortname) { $content = str_replace($search, $this->adjustLabelData($params, $data->subsortname, $label), $content); } else { $content = str_replace($search, '', $content); } break; case 'subsortico': if ($data->subsortico) { $content = str_replace($search, $this->adjustLabelData($params, $data->subsortico, $label), $content); } else { $content = str_replace($search, '', $content); } break;
对应的标签则是[list:subsortico]。
2,找到ParserModel.php,添加代码
路径:\apps\home\model\ParserModel.php
作用:调用数据库,从数据库中取出数据
修改:大约在300和415行,在“$fields = array(”里添加代码:
'c.ico as subsortico',
完整的实例:
$fields = array( 'a.*', 'b.name as sortname', 'b.filename as sortfilename', 'c.name as subsortname', 'c.filename as subfilename', 'c.ico as subsortico', 'd.type', 'd.name as modelname', 'd.urlname', 'e.*', 'f.gcode' );
3,最后在模板页面里添加自己新定义的标签[list:subsortico]
代码:
{pboot:list scode="15" page="0"} <li> <a href="[list:link]" class="p"><img src="[list:ico]" alt="[list:title]"></a> <img src="[list:subsortico]" class="mfg"> <s>[list:description len='100']...</s> </li> {/pboot:list}