<var id="xvh3p"><noframes id="xvh3p"><var id="xvh3p"></var><listing id="xvh3p"><strike id="xvh3p"><listing id="xvh3p"></listing></strike></listing>
<var id="xvh3p"><strike id="xvh3p"><var id="xvh3p"></var></strike></var><th id="xvh3p"><strike id="xvh3p"><th id="xvh3p"></th></strike></th>
<span id="xvh3p"><noframes id="xvh3p"><dl id="xvh3p"></dl>
<span id="xvh3p"><noframes id="xvh3p">
<dl id="xvh3p"><noframes id="xvh3p">
<listing id="xvh3p"><noframes id="xvh3p"><listing id="xvh3p"><strike id="xvh3p"><listing id="xvh3p"></listing></strike></listing><th id="xvh3p"><strike id="xvh3p"><th id="xvh3p"></th></strike></th>
<th id="xvh3p"><strike id="xvh3p"></strike></th>
<dl id="xvh3p"><noframes id="xvh3p">
<th id="xvh3p"><noframes id="xvh3p">

观点

互联网+时代,说建站,谈运营与网络营销

dedecms sql标签中调用其它变量值功能修改

时间:2020-12-21

织梦cms的代码除了自身的功能以外在模板标签调用以及自定义模型等方面确实很差,下面是是用sql标签调用匹配其他参数的代码修改:

一般在文章页使用sql标签匹配另外一个参数我们会按照以下这样写,但结果输出为空:
{dede:sql sql="select title from `dede_archives` where `title` like '%~pername~%'" db='default'}
  <li><a href='[field:arcurl/]'>[field:title/]</a> </li> 
{/dede:sql}
dedecms模板标签默认编译的结果就是select title from `dede_archives` where `title` like '~%pername%~' 并没有传递进来pername的参数。

此时我们需要对织梦cms的函数进行以下修改:
$sql = str_replace($conditions[0][$key], "'".addslashes($refObj->Fields[$value])."'", $sql);
修改为:(只需把引号去掉就可以实现了)
$sql = str_replace($conditions[0][$key], addslashes($refObj->Fields[$value]), $sql);

或者我们可以复制一份include/taglib/sql.lib.php重命名为likesql.lib.php并将对应代码修改,这样我们可以不影响{dede:sql sql=""}标签而用新的{dede:likesql sql=""}来实现模糊搜索。

0
首页
案例
关于
联系