Proper EE Tag Technique for an Unordered List Menu
Posted: 04 March 2009 08:28 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  60
Joined  04-26-2008

Hey all-

I’m sure I’ve got a simple problem to solve, but am having a hard time coding it properly.  I’ve had several EE “lightbulb” moments, but the bulb still flickers a bit from time to time.

I’ve got a JQuery accordion menu built, and I want to add an “expanded” class to a UL tag if the current entry matches the desired category. 

My menu code:

<ul id="menu1" class="menu">
   <
li><a href="#">Web</a>
      <
ul{exp:weblog:entries weblog="portfolio"}{if category_id =="4"class="expanded"{/if}{exp:weblog:entries}>
      
{exp:weblog:entries weblog="portfolio" dynamic="off" category="4"}<li><a path="portfolio">{title}</a></li>{/exp:weblog:entries}
      
</ul>
   </
li>
   <
li><a href="#">Print</a>
      <
ul{exp:weblog:entries weblog="portfolio"}{if category_id =="4"class="expanded"{/if}{exp:weblog:entries}>
      
{exp:weblog:entries weblog="portfolio" dynamic="off" category="5"}<li><a path="portfolio">{title}</a></li>{/exp:weblog:entries}
      
</ul>
   </
li>
</
ul

I don’t know the proper syntax to evaluate the current entry’s category value(s) This isn’t doing it:

{if category_id =="4"

nor is this, which I also tried:

{if "{category_id}"=="4"

Any ideas?  Thanks!

 Signature 

Ed Hebert | The Blue Ocean Design & Communications | Massachusetts, USA

Profile
 
 
Posted: 04 March 2009 08:30 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  26056
Joined  05-14-2004

Your category conditionals will need to go inside the {categories} variable pair. =)

 Signature 
Profile
MSG
 
 
Posted: 04 March 2009 09:04 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  60
Joined  04-26-2008

Ahhh - Thanks, Lisa!  That did the trick.

But now here’s another weird one.  The code that formerly worked fine (i.e., the code that listed *all* the entries for a particular category) now shows only the current entry in the menu list.  Somehow, in conjunction with the new tag, it’s not working.

<li><a href="#">Web</a>
     <
ul{exp:weblog:entries weblog="portfolio"}{categories}{if category_id =="4"class="expanded"{/if}{/categories}{exp:weblog:entries}
        
{exp:weblog:entries weblog="portfolio" dynamic="off" category="4"}<li><a path="portfolio">{title}</a></li>{/exp:weblog:entries}
     
</ul>
</
li

Do you see anything improper here?  As you see, I need all the entries for a particular category to build the menu (dynamic=off), but I need the value of the active entry in order to expand the proper submenu.

Thanks again.

 Signature 

Ed Hebert | The Blue Ocean Design & Communications | Massachusetts, USA

Profile