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 {switch} with HTML

October 30, 2007 3:12pm

Subscribe [1]
  • #1 / Oct 30, 2007 3:12pm

    Ben Kimball (UT)

    33 posts

    This is probably not how the {switch} variable was intended to be used, but this isn’t working for me:

    {exp:weblog:entries weblog="events" category="56" show_future_entries="yes" show_previous="yes"}
    {switch='<div class="day"><h2>{entry_date format="%l %F %Y"}</h2>|'}
    <div class="lecture">
        {entry_date format=""}: {title}
    </div>
    {switch='|</div>'}

    It looks like the first switch isn’t getting parsed, since “{switch=..." appears in the output.

    So for now I'm using the suggestion in this thread, which works but is a little wacky:

    {exp:weblog:entries weblog="events" category="56" show_future_entries="yes" show_previous="yes"}
    <!-- {switch="odd|even"} -->
    {if "{switch="odd|even"}" == "odd"}
    <div class="day">
        <h2>{entry_date format="%l %F %Y"}</h2>
    <p>{/if}<br />
    <div class="lecture"><br />
        {entry_date format=""}: {title}<br />
    </div><br />
    {if "{switch="odd|even"}" == "even"}<br />
    </div><br />
    {/if}<br />
    {/exp:weblog:entries}

    Is it possible to use {switch} with a bigger block of code, which includes quotation marks and embedded tags? Or is my problem that my second invocation of switch is overriding my first invocation somehow?

    Cheers,
    Ben

    P.S. Kudos to whomever wrote the syntax coloring code for these forums, that was quite the acid test.

    [Mod Edit: Moved to the How To forum.]

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

ExpressionEngine News!

#eecms, #events, #releases