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.

switch not working in query tag

October 19, 2010 12:56pm

Subscribe [3]
  • #1 / Oct 19, 2010 12:56pm

    kc37214

    1 posts

    Hi all,

    I am using EE 1.6.9 with the following code and the switch tag is not working. It’s using the first option (“one”) for each instance of the div.

    {exp:query sql="SELECT entry_id, entry_date FROM exp_weblog_titles WHERE weblog_id = {my_weblog_id} AND DATE(FROM_UNIXTIME(entry_date)) < NOW() LIMIT 1"}
        {exp:comment:entries  entry_id="{entry_id}" limit="15" sort="desc" category="2"}
            <div class="{switch="one|two"}">
               {comment}
            </div>
        {/exp:comment:entries}
    {/exp:query}

    You can see it here:
    http://leadingvoices.lipscomb.edu/onissue/

    It works on the page that uses a full URL path:
    http://leadingvoices.lipscomb.edu/onissue/what_do_you_think_the_legacy_of_governor_bredesen_will_be/

    But on that page, I’m not using the query tag.

    This is my first post here so go easy on me if I forgot to mention anything else!

  • #2 / Oct 20, 2010 2:39pm

    Digitaal Dier

    75 posts

    You have the site in offline-mode. Mind if we take a gander? 😊

  • #3 / Mar 16, 2011 11:03pm

    dirksnat

    38 posts

    I’m having the same problem.  Within {exp:query} the switch= variable only outputs one value.

    {exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '{segment_1}'"}
      {exp:channel:entries channel="mychannel" limit="1" dynamic="no" category="{cat_id}"}
        <div class="{switch='one|two|three'}">
          Stuff
        </div>
      {/exp:channel:entries}
    {/exp:query}

    The above outputs:

    <div class="two">
      Stuff
    </div>
    <div class="two">
      Stuff
    </div>
    <div class="two">
      Stuff
    </div>
  • #4 / Mar 17, 2011 12:57am

    Lisa Wess

    20502 posts

    That is because your tags are nested, and switch works for both the inner and outer tags, so it assumes the outer tag.

    If you embed your inner tag and pass the variables you need, switch should work.  Give it a shot. =)

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

ExpressionEngine News!

#eecms, #events, #releases