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.

Equivalent for Solspace's Selected for EE2?

August 25, 2010 6:01pm

Subscribe [4]
  • #1 / Aug 25, 2010 6:01pm

    Jack Tse

    67 posts

    Hi homEEs,

    Anybody been using something similar to Solspace’s Selected on a EE2 install yet to dynamically select and highlight list items with css yet?

    I kind of went ahead with EE2 for this client because all of Pixel Tonic add-ons were there but I didn’t realize Selected was not ported over yet. Yes, I totally took it for granted.

    Please help, and thanks!

    More info for Selected:

    http://www.solspace.com/software/detail/selected/

    “The Selected plug-in allows you to dynamically select the state of form elements and CSS objects at page load time. Some possible uses include highlighting a user’s current site location in the nav, or dynamically selecting form content based on user profiles.”

  • #2 / Aug 26, 2010 2:31pm

    Aaron Fowler

    113 posts

    Considering the amount of code “Selected” uses, it doesn’t seem too wordy to just use if statements:

    {preload_replace:active="class='selected'"}
    <ul id="nav">
        <li id="nav1"><a href="/">Home</a></li>
        <li id="nav2"><a href="/topics">Topics</a></li>
        <li id="nav3"><a href="/news">Daily News</a></li>
    </ul>

    HMMM - the if statements are being stripped out…

  • #3 / Aug 26, 2010 2:33pm

    Aaron Fowler

    113 posts

    Let’s try again

    {if segment_1="topics"}{active}{/if}
  • #4 / Aug 26, 2010 2:34pm

    Jack Tse

    67 posts

    You can email me: jacktse the at symbol gmail dot com

    I’ve never seen this method… thanks for helping.

  • #5 / Aug 26, 2010 2:47pm

    Jack Tse

    67 posts

    @Aaron Fowler -

    Thank you first of all.

    But it looks like that is a hard-coded list. So I may come back to this if I give up but I want it to dynamically evaluate the segment and replace.

    Boyink has a way that I’m looking at… I’m trying to figure it out still.

  • #6 / Aug 26, 2010 3:12pm

    Jack Tse

    67 posts

    Hi Boyink…

    I have been testing and I have no idea what your “trigger” is to make it only apply to the active page.

    Your Example: http://www.train-ee.com/images/weblog/active_class_nav.txt

    <div id="sidebar-a">
    <a href="/courseware/static/">Static Section Index</a>
    <!-- <li{if segment_3==url_title} class="active"{/if}><a href="http://{url_title_path=static/test}">{title}</a></li>   -->
    <ul>
    {exp:weblog:entries weblog="static"  sort="asc" offset="1" dynamic="off"}
    <li{if segment_3==url_title} class="active"{/if}><a href="http://{url_title_path=static/active_class}">{title}</a></li>
    {/exp:weblog:entries}
    </ul>
    </div>

    My code:

    <h3>About</h3>
    <p><ul><br />
    {exp:channel:entries channel="services" dynamic="no" offset="1" sort="asc" disable="pagination|member_data|categories|category_fields"}<br />
    <li {if segment_2=="{url_title}"}class="leftNav_current"{/if}><a href="http://{url_title_path=">{services_headline}</a></li><br />
    {/exp:channel:entries}<br />
    </ul>

  • #7 / Aug 26, 2010 3:15pm

    Boyink!

    5011 posts

    This approach assumes you are using a weblog:entries (or channel:entries) loop to generate nav, and the URL is displaying the url_title from an entry.

    {if segment_2=="{url_title}”}  would only apply to one of the entries being returned by the loop.

  • #8 / Aug 26, 2010 3:19pm

    Aaron Fowler

    113 posts

    The list doesn’t have to be hard coded.  You can output a nav list dynamically and compare segments to url_titles as well. 

    -Aaron

  • #9 / Aug 26, 2010 3:32pm

    Jack Tse

    67 posts

    This approach assumes you are using a weblog:entries (or channel:entries) loop to generate nav, and the URL is displaying the url_title from an entry.

    {if segment_2=="{url_title}”}  would only apply to one of the entries being returned by the loop.


    Does this line of code do anything? What does it mean?

    <!-- <li{if segment_3==url_title} class="active"{/if}><a href="http://{url_title_path=static/test}">{title}</a></li>   -->


    Thanks for helping BTW…

  • #10 / Aug 26, 2010 3:35pm

    Aaron Fowler

    113 posts

    Mike beat me to it 😊

    Jack, doesn’t your code example work?

    <h3>About</h3>
    <p><ul><br />
    {exp:channel:entries channel="services" dynamic="no" offset="1" sort="asc" disable="pagination|member_data|categories|category_fields"}<br />
    <li {if segment_2=="{url_title}"}class="leftNav_current"{/if}><a href="http://{url_title_path=">{services_headline}</a></li><br />
    {/exp:channel:entries}<br />
    </ul>

  • #11 / Aug 26, 2010 3:52pm

    Jack Tse

    67 posts

    Mike beat me to it 😊

    Jack, doesn’t your code example work?

    <h3>About</h3>
    <p><ul><br />
    {exp:channel:entries channel="services" dynamic="no" offset="1" sort="asc" disable="pagination|member_data|categories|category_fields"}<br />
    <li {if segment_2=="{url_title}"}class="leftNav_current"{/if}><a href="http://{url_title_path=">{services_headline}</a></li><br />
    {/exp:channel:entries}<br />
    </ul>

    No it doesn’t that’s why I’m incredibly frustrated!  :gulp:

    When I first started building EE websites 2 years ago, I remember struggling through this and discovering it doesn’t work. That’s why I use Selected. If this worked for everybody, why would Selected exist? I think I started using Selected from a 47media/longnecker blog post.

    However, I’m astounded by looking at Boyink’s example and flabbergasted that it works for him so easily… I’m trying everything here to try to get his results!

  • #12 / Aug 26, 2010 3:53pm

    Boyink!

    5011 posts

    Post your template code and the URL the page is displaying with.

  • #13 / Aug 26, 2010 4:02pm

    Jack Tse

    67 posts

    Post your template code and the URL the page is displaying with.


    http://website/index.php/services

    <div class="grid_3 alpha omega leftNav">
                    <h3>About</h3>
    <p>                <ul><br />
                        {exp:channel:entries channel="services" dynamic="no" offset="1" sort="asc" disable="pagination|member_data|categories|category_fields"}<br />
                        <li {if segment_2=="{url_title}"}class="leftNav_current"{/if}><a href="http://{url_title_path=">{services_headline}</a></li><br />
                        {/exp:channel:entries}<br />
                    </ul><br />
                </div>


    Latest EE2 build
    No plug-ins or modules or any add-ons installed


    Thanks!

  • #14 / Aug 26, 2010 4:13pm

    Boyink!

    5011 posts

    Is services a template group name, and this is in the index template?

  • #15 / Aug 26, 2010 4:15pm

    Jack Tse

    67 posts

    Is services a template group name, and this is in the index template?

    Yes,

    “Services” is an individual template group and the code for the left nav is in a chunked out template in the Services group named “leftnav”

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

ExpressionEngine News!

#eecms, #events, #releases