list_sections
  • hi

    currently have this

    {{ list_sections length="5" constraints="number greater 200" }} 
    {{ list_articles length="1" ignore_issue="true" ignore_section="false" order="bydate desc" constraints="onfrontpage is on" }}               


    but now i need to list section 120, 190, 220 260, 270 and nothing else

    cant find anything in the manual about adding extra 'number is' constraints
  • 4 Comments sorted by
  • Vote Up1Vote Down Micz FlorMicz Flor
    Posts: 184Administrator
    Well spotted, that does not exist. What we use is "set_section" in combination with "number". Below is an example from our sourcefabric.org site. Alternatively, you can climb your way through the usual "list_sections" and then inside use a chain of "if" "elseif". But the below example is easier to understand and maintain. It also contains the check if the section is chosen - to give it the class "current".

    {{ set_section number="23" }}
          <li{{ if $gimme->section->number == $gimme->default_section->number }} class="current"{{ /if }}>
          <a href="{{ uri options="section" }}" target="_top">{{ $gimme->section->description }}</a></li>
    {{ set_section number="24" }}
          <li{{ if $gimme->section->number == $gimme->default_section->number }} class="current"{{ /if }}>
          <a href="{{ uri options="section" }}" target="_top">{{ $gimme->section->description }}</a></li>
    {{ set_section number="21" }}
          <li{{ if $gimme->section->number == $gimme->default_section->number }} class="current"{{ /if }}>
          <a href="{{ uri options="section" }}" target="_top">{{ $gimme->section->description }}</a></li>


  • You can also exclude some sections by "number not <number>"

    For example,

    {{ list_sections constraints="number greater 9 number smaller 122 number not 110" }}

  • Hi Micz

    this has just listed the first 5 / 3 sections

    im using it for new caledonian / front-morenews.tpl and also front-morestories.tpl


    @Marina - same problem really - number is not 110  120  145 etc
  • Sorry about being late to the party here but I seem to remember the syntax is a little more complicated than that.

    Try instead:

    {{ list_section constraints="number not 1 number not 2 number not 3" }} …and so on.

    Post edited by Pete Haughie at 2013-04-16 08:17:32