这个问题还真是困扰我了,列表页能用$rs[picurl]获取文章中的图片,但在内容页里,用$rsdb[picurl]就不管用了,在内容页里显示的是红叉,我查看了那个IE解析出来的地址,少了upload_files/,而万能文章的内容页使用$rsdb[picurl]变量却是能直接调用。通过学习了一下万能文章那里的有关php文件,尝试了一下,果然成功了
修改方法:
打开根目录下的bencandy.php文件,查找:
if($rsdb[copyfromurl]&&!strstr($rsdb[copyfromurl],"http://")){
$rsdb[copyfromurl]=http://$rsdb[copyfromurl];
}
在其下面添加这么一段即可:
if($rsdb[picurl]){
$rsdb[picurl]=tempdir($rsdb[picurl]);
}else{
$rsdb[picurl]="$webdb[www_url]/images/default/nopic.jpg";
}
这样你就可以在内容页模板里,自由地使用$rsdb[picurl]变量来获取缩略图了。
使用方法:
在你使用的模块类型的内容页模板里合适的地方加上:<img border=0 src="$rsdb[picurl]">
这里默认生成的缩略图大小为200*150,如需要修改的话,可以对member/template/post.htm中,关于系统自动生成缩略图的大小进行更改,打开此文件后,找到:
<td width="15%">缩略图:</td>
<td width="85%">
<input type="text" name="postdb[picurl]" size="50" value="$rsdb[picurl]" id="picurl"> <input type="radio" name="postdb[automakesmall]" value="1" onclick="get_obj('cutimg_title').style.display='none';" checked>
系统自动截图
<input type="radio" name="postdb[automakesmall]" value="0" onclick="get_obj('cutimg_title').style.display='';">
手工截图
<span style="display:none;"> 宽:
<input type="text" name="picWidth" id="picWidth" size="3" value="200">
高:
<input type="text" name="picHeight" id="picHeight" size="3" value="150"></span>
将我红色标记的地方修改为自己需要的大小即可。
备注说明:
这个功能对于我们以后给企业建站有着非常大的用途,因为这样可以通过增加模块和自定义字段等功能,将内容页模板进行有效地排版.因为这里调用的是缩略图,即使你的文章中没有图片,你仍然可以在发表文章的时候,手动来添加.这也从另外一个方面丰富和美观了内容页.希望大家能喜欢!