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.

Select drop down channel field help?

July 30, 2013 12:19pm

Subscribe [2]
  • #1 / Jul 30, 2013 12:19pm

    Spenserkern

    1 posts

    Having some trouble using select drop down channel field. I just want to be able to publish content that would be displayed if an option is selected.

    I’ve been able to do it using html and js to show/hide divs based selection but I figured why not use the supplied EE channel field. Only thing is I can’t seem to find any resources on the matter.

    Thanks in advance,
    Spenser

  • #2 / Aug 02, 2013 6:53am

    Giraffentoast

    152 posts

    I think you’re mixing up some things here.
    EE provides the content, JS is the so called behaviour layer (it hides / shows things).

    The best way would be something like this:

    <select name="xxx">
    {exp:channel:entries}
    <option value="{url_title}">{title}</option>
    {/exp:channel:entries}
    </select>
    <ul>
    {exp:channel:entries}
    <li id="content-{url_title}">
    {title}
    {blabla}
    </li>
    {/exp:channel:entries}
    </ul>

    Then, hide every entry but the first via CSS.
    Use JS and onChange to show/hide the respective entry.

    And include a non-JS fallback through GET parameters.

    Writing this all down would take quite some time, sorry. 😉 Maybe you can narrow down your question?

  • #3 / Aug 03, 2013 3:21pm

    Rob Allen

    3114 posts

    If I get you right you want to display content based on the value of a select field on the publish page?

    If so here’s an example:

    Lets say you have a custom select field with 2 options, Yes/No, the author thene selects the relevent value.

    In your front end template all you’d need to do is use a conditional that “tests” the value of the select, eg

    {exp:channel:entries channel="my_channel"}
    
    {if your_select_field_name == "Yes"}
    {title}
    Your content
    {/if}
    
    {/exp:channel:entries}

    ... in this example, if the author has chose “Yes” then the content is output, if they select “no” then nothing is output.

    Another way to do this would be to use the search: parameter, an example:

    {exp:channel:entries channel="my_channel" search:your_select_field_name="Yes"}
    
    {title}
    Your content
    
    {/exp:channel:entries}

    ... in this example the channel entries tag will only display content when the select value is “Yes”.

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

ExpressionEngine News!

#eecms, #events, #releases