[SOLVED] how to hide sections without articles
  • Vote Up0Vote Down hhunorhhunor
    Posts: 16Member
    Hello!

    How to hide empty sections (sections that doesn't have any article) in list_section?

    Thank you!
    Hunor Habram
    Post edited by hhunor at 2014-05-12 15:05:32
  • 3 Comments sorted by
  • {{ list_sections }}              
        {{ if $gimme->current_list->at_beginning }}
            <ul>
        {{ /if }}
        {{ list_articles length="1" }}
        {{ /list_articles }}
        {{ if ! $gimme->prev_list_empty }}
            <li>
                <a href="{{ url options="section" }}">
                    {{ $gimme->section->name }}
                </a>
            </li>
        {{ /if }}
        {{ if $gimme->current_list->at_end }}
            </ul>
        {{ /if }}
    {{ /list_sections }}
  • Vote Up0Vote Down hhunorhhunor
    Posts: 16Member
    Thank you Sebastian for quick and great answer.

    You will notice that odd sections on the left side and even on right side.

    I do this (the following code), but when a section is missing, it will put two section on same side. We must put counter after filtering. But how?

    {{assign var="counter" value=0 }}
    {{ list_sections constraints="number greater 9 number smaller 21" }}
    {{ assign var="counter" value=$counter+1 }}
        {{ list_articles length="1" }}
        {{ /list_articles }}
        {{ if ! $gimme->prev_list_empty }}

    <aside class="extra-articles {{if $counter is odd}}left-block{{else}}right-block{{/if}}">
    <h4
    class="section-title"><a href="{{ uri options="section"
    }}"><b>{{ $gimme->section->name
    }}</b></a></h4>
        {{ list_articles length="4" ignore_issue="false" order="bysectionorder asc" }}
        <div class="link">
            <i class="icon-double-angle-right"></i>
            <a href="{{ uri options="article" }}"> {{ $gimme->article->cim }}
                    {{* <span> ({{ $gimme->issue->name }})</span> *}} </a>
        </div>
        {{ /list_articles }}
     <a href="{{ uri options="section" }}" class="solid-button pull-right">Még több</a>
    </aside>
       {{ /if }}
    {{ /list_sections }}


    Here is the class assigned to sections. Notice the two left block one after another>

    <aside class="extra-articles left-block"></aside>
    <aside class="extra-articles right-block"></aside>
    <aside class="extra-articles left-block"></aside>
    <aside class="extra-articles left-block"></aside>
    <aside class="extra-articles right-block"></aside>
    <aside class="extra-articles left-block"></aside>
    <aside class="extra-articles right-block"></aside>

    Post edited by hhunor at 2014-05-12 14:55:17
  • Vote Up0Vote Down hhunorhhunor
    Posts: 16Member
    I solved it!

    The line
    {{ assign var="counter" value=$counter+1 }}

    put after IF statement:

    ...
        {{ if ! $gimme->prev_list_empty }}
    {{ assign var="counter" value=$counter+1 }}
    <aside class="extra-articles {{if $counter is odd}}left-block{{else}}right-block{{/if}}">
    ...

    and it is working!

    Thank you Sebastian one more time!