帝国cms转wordpress(帝国cms相关文章调用)
操作方法如下:
1.将以下代码放入/e/class/userfun.php中(放在最后一个?之前)
functionuser_imgalt($mid,$f,$isadd,$isq,$value,$cs){$title=$_POST['title'];$htmls=$value;$pattern='/img[^]+/' ;preg_match_all($pattern,$htmls,$matches);for($i=0;$i=count($matches[0]);$i++){preg_match_all('/alt='.+?'/', $matches[0][$i],$altimg);preg_match_all('/title='.+?'/',$matches[0][$i],$titleimg);$t_alt=count($altimg[ 0]);if($t_alt==0){$htmls=str_replace('img','imgalt='{$title}'',$htmls);$htmls=str_replace('img','imgtitle=' {$title}'',$htmls);}}返回$htmls;}2.在模型中,文本字段通常是新闻文本(也可以是其他字段)。在字段处理函数文本框中填写user_imgalt,如下图:
3、这样在帝豪CMS后台发布信息时,就可以自动将图片alt和title属性替换为信息标题了!