New plugin:Selected
Posted: 25 May 2007 11:59 AM   [ Ignore ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

This plugin makes it easy for you to dynamically select the states of form elements and CSS objects at page load time. You pass the value you’re evaluating in the item parameter. That will always be some sort of variable, like a segment. Then you use a variable to handle the output of the selected state.

To give you an example:

<ul id="nav">
{exp:selected item="{segment_1}" replace="class=’selected‘“}
<li id="
nav1" class="first"><a href="/" {selected_null}>Home</a></li>
<li id="
nav2"><a href="/topics" {selected_topics}>Topics</a></li>
<li id="
nav3"><a href="/news" {selected_news}>Daily News</a></li>
<li id="
nav5"><a href="/archives" {selected_archives}>Archives</a></li>
<li id="
nav7"><a href="/subscribe" {selected_subscribe}>Subscribe</a></li>
<li id="
nav8"><a href="/advertisers" {selected_advertisers}>Advertisers</a></li>
{/exp:selected}
</ul> <!-- nav -->

Whenever “item” is matched, it is replaced. In the case of www.example.com/archives, this would result in this rendered code:

<ul id="nav">
<
li id="nav1" class="first"><a href="/">Home</a></li>
<
li id="nav2"><a href="/topics" class="selected">Topics</a></li>
<
li id="nav3"><a href="/news">Daily News</a></li>
<
li id="nav5"><a href="/archives">Archives</a></li>
<
li id="nav7"><a href="/subscribe">Subscribe</a></li>
<
li id="nav8"><a href="/advertisers">Advertisers</a></li>
</
ul> <!-- nav -->

More information here.

 Signature 

Ingmar Greil

Profile
 
 
Posted: 21 August 2007 04:01 PM   [ Ignore ]   [ # 1 ]
Member
Avatar
RankRankRank
Total Posts:  60
Joined  2005-03-31

Wouldn’t the TOPICS in the example not be selected?

TTFN
Travis

Profile
 
 
Posted: 22 August 2007 10:20 AM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  693
Joined  2004-03-30

If the value of segment_1 = topics, topics would be the selected item in the list. Que no?

mk

 Signature 

Mitchell Kimbrough

Profile
 
 
Posted: 22 August 2007 04:12 PM   [ Ignore ]   [ # 3 ]
Member
Avatar
RankRankRank
Total Posts:  60
Joined  2005-03-31

Yes, but the example says it’s /archives, and the example also shows “archives” selected.

Whatever, I’m just being picky.

TTFN
Travis

Profile
 
 
Posted: 22 August 2007 05:33 PM   [ Ignore ]   [ # 4 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  693
Joined  2004-03-30

right ok. edited. thanks

 Signature 

Mitchell Kimbrough

Profile
 
 
   
 
 
     New Video module in beta ››