ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Multiple Conditions issue

January 18, 2010 8:22am

Subscribe [4]
  • #1 / Jan 18, 2010 8:22am

    Darrell Wilson

    23 posts

    Hi,

    I’m having problems with a seemingly simple conditional on the following page - http://www.project-ability.co.uk/blog

    By default I want the blog to display blog entries by month. The page also displays blog entries by Category - these should not be limited by month as we want to see all entries in a category. Also - we want to display the latest 5 blog entries on the page.

    I can conditionally exclude the display_by=“month” parameter by checking URL segment_2 for the ‘category’ trigger:

    {exp:weblog:entries weblog="{my_section}" disable="trackbacks" dynamic="on" {if segment_2 != "category"}display_by="month"{/if}}

    But - if an entry is included in the ‘Latest Posts’ list but it’s entry date wasn’t within the current month then it can’t be displayed. The obvious solution is to only include the display_by=“month” parameter if segment_2 is empty (ie. the default blog url - no URL title specified) or if segment_2 does not contain the ‘category’ trigger.

    {exp:weblog:entries weblog="{my_section}" disable="trackbacks" dynamic="on" {if segment_2 == "" OR segment_2 != "category"}display_by="month"{/if}}

    This works in that it turns off the display_by parameter if segment_2 is ‘category’; it also turns off display_by if there is a url_title. The problem is that it is not including the ‘display_by’ for the default blog url (ie. no url title an no category)

    Hope that makes sense - any advice appreciated.

    Darrell

  • #2 / Jan 18, 2010 5:21pm

    Ingmar

    29245 posts

    I am afraid using {if ...} statements to break up a tag like that is not supported, at all. I am not too sure about what exactly you’re trying to achieve here, but you might have to rethink your approach a little. Use multiple (complete) tag pairs.

  • #3 / Jan 21, 2010 6:06pm

    Latitude 10

    18 posts

    I could to something like:

    <?php
       global $IN;
    ?>
    {exp:weblog:entries weblog="{my_section}" disable="trackbacks" dynamic="on" <?php if($IN->SEGS[3] != ""){ echo '{if segment_2 == "" OR segment_2 != "category"}{/if}';}?>}

    Obviously, we have to change the parse order of the template. But that could work.

  • #4 / Jan 21, 2010 9:00pm

    Adam Dorsey

    1439 posts

    You would have to do something like this:

    {if segment_2 != "category"}
    {exp:weblog:entries weblog="{my_section}" disable="trackbacks" dynamic="on"}
    ..
    {/exp:weblog:entries}
    {/if}
    
    {if segment_2 == "" OR segment_2 != "category"}
    {exp:weblog:entries weblog="{my_section}" disable="trackbacks" dynamic="on" display_by="month"}
    ..
    {/exp:weblog:entries}
    
    {/if}

    So basically wrapping the conditional around the entire weblog tags. This will perform well, as it will only parse if the conditional returns TRUE.
    Does this help?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases