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.

Categories/Channel issues

March 13, 2012 11:21pm

Subscribe [1]
  • #1 / Mar 13, 2012 11:21pm

    Center Stage

    6 posts

    Maybe I’m misunderstanding what the purpose of categories are. But this is what I’m trying to accomplish.

    I have a channel and 5 categories. My channel entries are split between those categories.
    when I click on a category, it goes to the category page where it lists the entries in that category. My issue is: 1. When I click on an entry to go to that entry’s detail page, how do I show both the category title url and the specific entry title url? so http://www.sitename.com/template-name/category-title-url/entry-title-url

    2. on the entry detail page, I also have the list of entries below the entry detail so the user doesn’t have to go back to the category page to pick the next entry. I have the dynamic=off parameter, however, it lists all the entries for that channel and not just the ones for that category. Is that possible to just list the entries for a particular category on a entry detail page? Below is a rough sample of how the detail page is. If there was a way to dynamically put the category id in the parameters based on what category that entry is assigned to I could put the category=”” parameter in there, but I’m not sure how to do that without creating a new template for each category and statically calling it out.

    {exp:channel:entries channel="channel_name" limit="1" order_by="custom-field" sort="asc"}
    {title}
    {body}
    {custom_field}              
    {/exp:channel:entries}
    {exp:channel:entries channel="channel_name" order_by="custom_field" sort="asc" dynamic="no"}
    <li><a href="http://{title_permalink=">Link to entry</a>
    {/exp:channel:entries}
  • #2 / Mar 14, 2012 5:49pm

    Dan Decker

    7338 posts

    Hi Center Stage,

    What you are after is certainly possible!

    For constructing your URLs, you would have this pattern:

    <a href="http://domain.com/template-group/template/category/category_url_title/url_title">http://domain.com/template-group/template/category/category_url_title/url_title</a>

    If you use the index template of your template-group to do all of the work, you can whittle it down to:

    <a href="http://domain.com/template-group/category/category_url_title/url_title">http://domain.com/template-group/category/category_url_title/url_title</a>

    Where “category” is your Category URL Indicator as set in Admin->Channel Administration->Global Preferences. You also want to make sure that Use Category URL Titles In Links? is set to “Yes”.

    If you don’t want to include the Category URL Indicator in your URLs, you can use Seg2Cat to translate URL segments into category ID information that you can pass dynamically to channel entries tags.

    For the second questions try this:

    {exp:channel:entries channel="channel_name" limit="1" order_by="custom-field" sort="asc"}
    {title}
    {body}
    {custom_field}              
    {/exp:channel:entries}
    {exp:channel:entries channel="channel_name" order_by="custom_field" sort="asc"}
    <li><a href="http://{title_permalink=">Link to entry</a>
    {/exp:channel:entries}

    I look forward to your reply!

    Cheers,

     

  • #3 / Mar 14, 2012 9:43pm

    Center Stage

    6 posts

    Thanks for your reply. I’m still have issues with the list of the entries below the single entry. If I don’t have the dynamic=“no” parameter then when I click on an entry link, then when that single entry shows only that link shows in the list where I want all of them in that category to show. If I take the dynamic=“no” out, when I click on an entry link then when that entry shows, the whole list shows, but so do all the entries links in that channel and not just the ones from the category that the entry is from. Also I’m having issue getting the category url title to show with the single entries.

    so below, is the section of all the entry links that are below the single entry. How would I write the href so that the category would show in the url? How I have it now isn’t working.

    {exp:channel:entries channel="channel_name" order_by="custom_field" sort="asc"}
        <li><a href="http://{title_permalink="><span>Lesson {lesson_order}</span>{video_screen_shot}</a></li>
    {/exp:channel:entries}
  • #4 / Mar 16, 2012 2:45pm

    Dan Decker

    7338 posts

    Hey Center Stage,

    Sorry! I left out a rather critical bit.

    {title_permalink} does not support parameters like id= I meant to include an example in my reply.

    {categories}
    <a href="{title_permalink='template-group/category/{category_url_title}'}">
    {/categories}

    Give that a run and let me know if you have any questions!

    Cheers,

  • #5 / Mar 17, 2012 12:02pm

    Center Stage

    6 posts

    cool… thanks! That worked.

  • #6 / Mar 19, 2012 2:11pm

    Dan Decker

    7338 posts

    Hi Center Stage,

    I’m so glad I was able to help!

    If you ever need anything else, just start a new thread.

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases