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.

Using month link variables in a conditional

August 04, 2009 3:55pm

Subscribe [2]
  • #1 / Aug 04, 2009 3:55pm

    Adam Dorsey

    1439 posts

    I’m pretty sure it isn’t possible, but it would be useful if the variables {month} and {year} were available in conditionals, so I could place an “active class in the <li>

    For example:

    <h3>Archives</h3>
    <p>        <ul><br />
                {exp:weblog:month_links weblog="news" dynamic="off" status="not closed" limit="30"}<br />
                <li{if segment_3 == "{month}" AND segment_4 == "{year}"} class="here"{/if}><a href="http://{path=news/archives}">» {month}, {year}</a></li><br />
                {/exp:weblog:month_links}<br />
            </ul>

  • #2 / Aug 05, 2009 8:30pm

    e-man

    1816 posts

    I’m pretty sure it isn’t possible, but it would be useful if the variables {month} and {year} were available in conditionals, so I could place an “active class in the <li>

    For example:

    <h3>Archives</h3>
    <p>        <ul><br />
                {exp:weblog:month_links weblog="news" dynamic="off" status="not closed" limit="30"}<br />
                <li{if segment_3 == "{month}" AND segment_4 == "{year}"} class="here"{/if}><a href="http://{path=news/archives}">» {month}, {year}</a></li><br />
                {/exp:weblog:month_links}<br />
            </ul>

    Huh, I thought the whole point of an archive was to collect past events? 😊
    Seriously now, this is easily fixed with php’s date function:

    <h3>Archives</h3>
    <p>        <ul><br />
                {exp:weblog:month_links weblog="news" dynamic="off" status="not closed" limit="30"}<br />
                <li{if segment_3 == "<?php echo date(m); ?>" AND segment_4 == "<?php echo date(y); ?>"} class="here"{/if}><a href="http://{path=news/archives}">» » {month}, {year}</a></li><br />
                {/exp:weblog:month_links}<br />
            </ul>

    this assumes your segments look like /03/09/ for march 2009, if they have another formatting check php.net for the proper formatting.
    Set php in your templates to output.

  • #3 / Aug 07, 2009 5:04pm

    Adam Dorsey

    1439 posts

    Huh, I thought the whole point of an archive was to collect past events?

    I’m not sure what you mean here…

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

ExpressionEngine News!

#eecms, #events, #releases