Twig 在页面过滤器中使用数组变量
这是密码Twig 在页面过滤器中使用数组变量,twig,octobercms,Twig,Octobercms,这是密码 <a href="{{ 'questions' | page({Filter[search] : 1}) }}">{{category.name}}</a> 我做错了什么?嗯,这样不行 您的url类似于以下url=/vos questions/:页面?所以Page必须是参数,它会被认为是这样的< /P> /vos-questions/test => now in code `page` param's value will be `test` 如果你真
<a href="{{ 'questions' | page({Filter[search] : 1}) }}">{{category.name}}</a>
我做错了什么?嗯,这样不行
您的url类似于以下url=/vos questions/:页面?所以Page必须是参数,它会被认为是这样的< /P>
/vos-questions/test => now in code `page` param's value will be `test`
如果你真的需要这个url,那么有更好的解决方案
// question page
title = "questions"
url = "/vos-questions" <- we remove param here as we pass it manually
// now html code
<a href="{{'questions'|page }}?Filter[search]=1&Filter[categories]=3&
Filter[sort]=published_at+desc">{{category.name}}</a>
如果有任何疑问,请发表评论。有效!我不知道这是否是解决它的“规范”方法,但它确实有效。不,这不是规范的方法,但对于大量的过滤器,您需要这样做,对于较小的集合,您可以像/vos questions/:search/:category/:sort那样使用{{“questions”| page{search:1,'category':}手动传递3个参数,但它只适用于较短的数据
// question page
title = "questions"
url = "/vos-questions" <- we remove param here as we pass it manually
// now html code
<a href="{{'questions'|page }}?Filter[search]=1&Filter[categories]=3&
Filter[sort]=published_at+desc">{{category.name}}</a>
// suppose $search = 2 in code and $cat = 30
<a href="{{'questions'|page }}?Filter[search]={{ search }}
&Filter[categories]={{ cat }}
&Filter[sort]=published_at+desc">{{category.name}}</a>
$filter = \Input::get('Filter');
echo $filter['categories']; // => 30