织梦后台模型添加自定义字段,数据类型用单行文本(varchar),用来填要调用的相关文章的id
织梦模板里写dede:sql标签
{dede:sql sql="SELECT * FROM dede_archives WHERE arcrank>-1 AND id in(~自定义字段名~) ORDER BY FIELD(id,~自定义字段名~)"}
<a href=https://www.91084.com/"[field:id runphp=yes]$id=@me;$url=GetOneArchive($id);@me=$url['arcurl'];[/field:id]"><img src=https://www.91084.com/"[field:litpic/]">[field:title/]</a>
<p>[field:description/]</p>
{/dede:sql}
~自定义字段名~改成你的字段例如~gezhan~
打开 /include/taglib/sql.lib.php文件
找到
<span style="font-size:14px;">$sql = str_replace($conditions[0][$key], "'".addslashes($refObj->Fields[$value])."'", $sql);</span>
改成
<span style="font-size:14px;">if(is_numeric(str_replace(',','',$refObj->Fields[$value])))
{
$sql = str_replace($conditions[0][$key], addslashes($refObj->Fields[$value]), $sql);
}
else
{
$sql = str_replace($conditions[0][$key], "'".addslashes($refObj->Fields[$value])."'", $sql);