twig - Passing variable value inside setcontent in bolt.cm -


i'm using framework called bolt.cm. simple framework based on silex. there twig function records of specific contenttype :

{% setcontent products = 'products' %} 

to record , order them specific field :

{% setcontent products = 'products' orderby 'datepublish' %} 

above fetch records ordered datepublish field. now, wanted pass orderby field parameter. store parameter in global twig variable passed controller, defined sort_by variable.

{{ sort_by }} 

above print sort_by value html. in page : /products?sort_by=datepublish set sort_by value datepublish i'm going combine variable setcontent function described below :

{% setcontent products = 'products' orderby sort_by %} 

now i'm getting error :

an exception has been thrown during compilation of template ("attribute "value" not exist node "twig_node_expression_name".") in "products.twig". 

my question simply, how make sort_by recognized value inside function ? please don't tell me :

{% if sort_by == 'datepublish' %}   {% setcontent products = 'products' orderby 'datepublish' %} {% elseif sort_by == 'another_field' %}   {% setcontent products = 'products' orderby 'another_field' %}  {# , on every single field #}  {% endif %} 

which version of bolt using? should possible since version 1.6. release notes say:

you can use variables in {% setcontent %} tags, this: {% setcontent mypages = 'pages' order my_var limit other_var %}.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -