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 Dropdown' category specifies what channel enties to appear.

November 16, 2011 7:10am

Subscribe [2]
  • #1 / Nov 16, 2011 7:10am

    ZEDG

    32 posts

    Hi,
    I tried searching for what i want to do but i wasnt sure how to word it (or if its possible).

    I have three content pages, each for ‘youth’, ‘family’, and ‘community’. (The 3 of these appear under the MEDIA template).

    I can obviously have three different channels for each of those. The user then being able to create a new entry for the, eg. video_youth channel, and that entry will appear on the ‘youth’ page.

    What i want to do however, is have only one channel ‘videos’. Within it will be a field of type ‘select dropdown’. The menu would be populated with the categories ‘youth’, ‘family’, or ‘community’.

    Now when the user creates a new videos entry, they select a category from the dropdown, and the entry will appear on the relevant page.

    So i have a ‘video’ template showing how the video content is to appear.

    {exp:channel:entries channel="video" sort="desc" dynamic="no"}
    <h2>{title}</h2>
    <p>{vid_info}<br />
    <iframe src="http://player.vimeo.com/video/{vid_id}?title=0&byline=0" width="450" height="253" frameborder="0"></iframe><br />
    {/exp:channel:entries}

    What code do i need to place onto the MEDIA template, to embed the above - but make sure that only the specific entries for the category that was selected appear?

    So if someone viewing the page selects media > youth, obviously only the youth (category) entries appear.


    ANY help is appreciated!

  • #2 / Nov 16, 2011 7:37am

    Cubic

    5 posts

    Hi,

    You could do this with the built in categories functionality the EE has. So you would create a new Categories group and add the categories youth, family, community. Then you assign this category group to your Video channel. When creating a new entry the user can choose the category they want. Then you can filter it by adding the category parameter to your exp:channel:entries loop see (http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#category) or you can set your page URL to look something like this ...com/videos/category/family and EE should filter it for you.

    Alternatively if you didn’t want to use categories to do this you could add some custom field types that allow the user to select form a predefined list. Pixel & Tonic do some good ones see (http://pixelandtonic.com/divebar). If you used this you could filter your exp:channel:entries loop with (http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#search-field-name)

    Hope that helps

  • #3 / Nov 16, 2011 10:06am

    ZEDG

    32 posts

    Thanks.
    Ok so i used your second alternative, downloaded and installed the custom field types.

    The short name for the ‘category’ field (using the P&T Radio Buttons) is vid_category.
    I have added the 3 options.

    From what you are saying, is the below correct?
    <br /> {exp:channel:entries channel="video" sort="desc" dynamic="no" search:vid_category="=Youth|Family|Community"}<br />

    Or what does it need to be changed to?

    Now on my MEDIA template, how do i embed the ‘videos’ template?
    It currently has a few ‘if’ statements already on it:

    <br /> {exp:channel:entries channel="content_page"}<br /> <h1>{title}</h1><br /> <div id=“body”><br /> {content}<br /> {if entry_id == "132"}<br /> {embed="ignore_includes/newsletter"}<br /> {/if}<br /> {if entry_id == "131"}<br /> {embed="ignore_includes/in-the-news"}<br /> {/if}<br /> {if entry_id == "129"}<br /> {embed="ignore_includes/media-releases"}<br /> {/if}<br /> {if entry_id == "130"}<br /> {embed="ignore_includes/library"}<br /> {/if}<br /> </div><br /> {/exp:channel:entries}<br />

    There is a content_page (channel) entry for each of my categories (youth,family,community).

    So if someone clicks on the Youth Videos link in the menu, they should get the MEDIA template, showing the Youth Videos content_page channel entry - that has the videos template embedded - which will bring up all entries that relate to the vid_category (field) category of Youth.

    So confused.!?

  • #4 / Nov 16, 2011 11:21am

    Cubic

    5 posts

    Hmm, I’m a little confused now as well 😊

    Can you explain your channels a bit more. You have one channel called content_page which contains all the page content and another called ‘videos’ which holds the actual videos. Is that correct?

  • #5 / Nov 16, 2011 11:33am

    Cubic

    5 posts

    If that is the case then you may not need to change anything in the page_content channel.

    Say your page url is:

    site.com/videos/family

    You can get the category name ‘family’ from that second segment with

    {segment_2}

    Then when you run your videos loop like this:

    {exp:channel:entries channel=“video” sort=“desc” dynamic=“no” search:vid_category=”{segment_2}”}

    You will get all of the videos with the vid_category of ‘family’.

    Note. Make sure you don’t run this loop within your {exp:channel:entries channel=“content_page”} loop as this will cause problems.

  • #6 / Nov 17, 2011 2:38am

    ZEDG

    32 posts

    Ok this is my navigation:

    Media
      In The News
      Media Releases
      Videos
        -Youth
        -Family
        -Communtiy
      Library
      Newsletter


    Everything under Media uses the same template - Media/index.

    There is a channel called content_page. Every page in the site has a content_page entry

    On the Media template, i currently have this code:

    {exp:channel:entries channel=“content_page”}
    <h1>{title}</h1>
    <div id=“body”>
    {content}
    {if entry_id == “131”}
    {embed=“ignore_includes/in-the-news”}
    {/if}
    {if entry_id == “132”}
    {embed=“ignore_includes/media-releases”}
    {/if}
    {if entry_id == “133”}
    {embed=“ignore_includes/library”}
    {/if}
    {if entry_id == “134”}
    {embed=“ignore_includes/newsletter”}
    {/if}
    </div>
    {/exp:channel:entries}

    So for example, if we are on the library page, which has a content_page channel entry of 133, then it embed the template called library.

    Each of the 4 templates noted have their own channel associated with it.
    For example, the library template starts off with:

    {exp:channel:entries channel="library" sort="desc" dynamic="no"}


    1. So based on this, I need to know what code to place onto the Media template, to tell it to load the Videos template..

    {embed=“ignore_includes/videos”}

    ..if either the youth, family or community pages is visited. And obviously the related content_page channel entry appears.

    The first thing that comes to mind would be..

    {if entry_id == “135”}
    {embed=“ignore_includes/videos”}
    {/if}
    {if entry_id == “136”}
    {embed=“ignore_includes/videos”}
    {/if}
    {if entry_id == “137”}
    {embed=“ignore_includes/videos”}
    {/if}

    .. where 135 is the content_page entry for youth, 136 for family.. and so on.

    Now since each of those is loading the exact same template, this is obviously not how you would code this. I need to know how.

    ..


    Now for the Videos channel, there is a field called vid_category.
    (This uses the ‘P&T Radio Buttons’ type).

    This consists of the three options: Youth, Family, Community

     

    So I have the Videos template which currently has this:

    {exp:channel:entries channel="video" sort="desc" dynamic="no"}
    <h2>{title}</h2><p>{vid_info}<br />
    <iframe src="http://player.vimeo.com/video/{vid_id}?title=0"></iframe><br />
    {/exp:channel:entries}


    2. I need to know what code to place within this to tell it to load the relevant vid_category option, based on the initial page i am on (noted earlier).


    (I understand that 2. might not be requried based on what is placed for 1. (??))


    Does this clear my predicament up?
    I really appreciate any help on this.

  • #7 / Nov 17, 2011 4:48am

    Cubic

    5 posts

    Ok I think I get it now. I would suggest you look at using url segments instead of entry ids. (http://ellislab.com/expressionengine/user-guide/templates/globals/url_segments.html)

    Assuming that the structure of your URL is like this:

    media/in-the-news or media/video etc

    Instead of this:

    {if entry_id == “131”}
    {embed=“ignore_includes/in-the-news”}
    {/if}
    {if entry_id == “132”}
    {embed=“ignore_includes/media-releases”}
    {/if}
    {if entry_id == “133”}
    {embed=“ignore_includes/library”}
    {/if}
    {if entry_id == “134”}
    {embed=“ignore_includes/newsletter”}
    {/if}

    You could do this

    {embed=“ignore_includes/{segment_2}”}

    This uses the second segment of the url (which should be the same name as the template file for that page)

    Then for this url:

    media/video/family

    You could have this code in your video template, exactly the same as you already have but with the search:vid_category=”{segment_3}” param added to your loop.

    {exp:channel:entries channel="video" sort="desc" dynamic="no" search:vid_category=”{segment_3}”}
    <h2>{title}</h2><p>{vid_info}<br />
    <iframe src="http://player.vimeo.com/video/{vid_id}?title=0"></iframe><br />
    {/exp:channel:entries}

     

  • #8 / Nov 17, 2011 5:47am

    ZEDG

    32 posts

    Thanks.

    I have changed the code as you have specified, but this does not work. The channel entires no longer appear on their subsequent pages.

    ?

    ps. There is no ‘videos’ template under media template group.
    So the url is .au/media/youth-videos not .au/media/videos/youth

  • #9 / Nov 17, 2011 5:57am

    Cubic

    5 posts

    Hmm, ok well I suggest you go back to the code you had in your last post (#5)

    Then have a look at how to pass variables through to embed templates.

    http://ellislab.com/expressionengine/user-guide/templates/embedding.html#embed-variables-for-the-embedded-template

    Good luck with it, hope you manage to figure it out.

  • #10 / Nov 21, 2011 8:35am

    ZEDG

    32 posts

    I have come back to this.

    Using segment_1, _2 or _3 never seemed to work, however i tried last_segment which works great. Just a new question though.

    When the user adds a new video, it appears on the home page of the website. I have this code below, but i am not sure what i need to make the href=”” ?

    {if channel_short_name == "video"}
    /images/video.gif
    <h2><a href="http://" title="{title}">{title}</a></h2>
    <p>{/if}

    It would link to the entry on the relevant video page, eg. “media/videos/youth#{title}”
    (How does it work out the ‘youth’ page).

    Update.
    Just worked out all i needed to place was the field name {vid_category}
    “media/videos/{vid_category}#{title}”

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

ExpressionEngine News!

#eecms, #events, #releases