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.

category template help

August 31, 2011 7:28pm

Subscribe [3]
  • #1 / Aug 31, 2011 7:28pm

    stevo_s

    176 posts

    Hi - trying to get this category template to work but having no joy. Maybe I’ve set-it up wrong but there’s no info in the user guide.

    Global Category URL Indicator is ‘category’


    url structure is index.php/portfolios/gallery/artists_page

    gallery template has

    <a href="http://{path=/categories}">{category_name}</a>

    I’ve created a category page template called ‘categories’ with:

    {exp:channel:entries channel="portfolios" orderby="{segment_3}" dynamic="off"  sort="desc"  limit="25"}
    
    {if count==1}<h3>{category_name}<h3>{/if}
    
    <a href="http://{thumbnail}%22rel=%22group" rel="group" title="{caption}" class="tip7">{thumbnail}{path}_thumb_folio/{filename}.{extension}{/thumbnail}</a>
    
    {paginate} Page {current_page} of {total_pages} pages {pagination_links}{/paginate}
    {/exp:channel:entries}


    but it isn’t ordering by the category_name

    also <h3>{category_name}<h3> isn’t showing the category name. I’ve tried orderby segment_4 but that is the same result.

    Any ideas what i have done wrong here?

  • #2 / Sep 01, 2011 11:06am

    Kevin Smith

    4784 posts

    Hi stevo_s,

    First thing I noticed is the forward-slash you have in:

    {path='/categories'}

    That doesn’t need to be there, so go ahead and remove it.

    Perhaps a bit more context in your code would help me help you. Is this:

    <a href="http://{path=categories}">{category_name}</a>

    within a category variable pair inside the Channel Entries tag? When someone clicks on that, what does the intended URL look like? And does it actually look the way you want?

    And the resulting category page, the partial template of which it looks like you posted, what’s the intended goal of that template? (I’m assuming the third segment of the URI string is supposed to be the category name, yes?)

  • #3 / Sep 01, 2011 11:19am

    stevo_s

    176 posts

    Yes, actually I’m just thinking - am I better off putting this in my index template -

    {if segment_2=="category"}

    and avoiding a category template?

    thing is my portfolios/index is just a list of folios. but portfolios/gallery is a template of the individual folio.
    But my categories sidebar list would be in both templates. But I presume the default is to use the index template as the category template so I should try to put everything into that?

    Doesn’t seem to be a lot of documentation on best practice for this.

  • #4 / Sep 01, 2011 12:18pm

    stevo_s

    176 posts

    Seems like the

    {if segment_2=="category"}

    strategy might be best.


    But any idea why

    {categories}
    <a href="http://{path=}">{category_name}</a>
    {/categories}

    wouldn’t be showing the correct category names in the list the image is in? the link url is right but the name just repeats the same name of the category page 3 times - design design design . Is there another way to grab the categories list an image would be in?

    {if segment_2=="category"}
    {exp:channel:category_heading channel="portfolios"}
    <h1>{category_name}</h1>
    
    {exp:channel:entries channel="portfolios" orderby="date" dynamic="on"  sort="desc"  limit="22"}
    
    <a href="http://{thumbnail}%22rel=%22group" rel="group" title="{caption}" class="tip7">{thumbnail}{path}_thumb_folio/{filename}.{extension}{/thumbnail}</a>
    {screen_name}
    
    {categories}
    <a href="http://{path=}">{category_name}</a>
    {/categories}
    
    {paginate} Page {current_page} of {total_pages} pages {pagination_links}{/paginate}
    {/exp:channel:entries}
  • #5 / Sep 02, 2011 1:35pm

    Kevin Smith

    4784 posts

    I’m still having trouble understanding your ultimate goal here, and I don’t know how you have your data structured. This makes it hard to offer a solution. It sounds like you want two templates:

    portfolios/index
    This will be a listing of all portfolios, which, as far as I can gather, 1 portfolio = 1 entry. All portfolios are within a single channel named…. ‘portfolios’?

    portfolios/gallery
    This would be a page with data pulled from a single channel entry within the portfolios channel.

    Within both templates, you want a listing (with links) of all categories from the category group that is assigned to the portfolios channel. Those links, when clicked, will take the user to a page similar to the portfolios/index template, but that is filtered to show only entries from the category that was clicked.

    Is that the user experience you’re trying to achieve? If so, that’s possible and I can help point you in the right direction. If not, please let me know what experience you are trying to achieve with the kind of detail that I used above. ExpressionEngine is such a flexible platform that there are nearly endless ways of structuring and displaying your content. Unfortunately, it makes guessing what you’re trying to accomplish nearly impossible. 😉

  • #6 / Sep 02, 2011 1:55pm

    stevo_s

    176 posts

    Is that the user experience you’re trying to achieve?

    Yep pretty much. Sorry for my messy explanation.

    The index template actually just has the list of folios. The gallery has the actual entries. And the category result page would look more like the gallery template than the index template. But what I have working at the moment is the if segment_2==“category” in the index template that holds the category results. So I reckon that should do the trick unless you think this is a bad strategy. I just wasn’t sure as there is so little documentation on this stuff in the EE website.

  • #7 / Sep 04, 2011 9:54pm

    Dan Decker

    7338 posts

    stevo_s

    I’m happy to see you have a method that works for you. The best practices/good strategy with ExpressionEngine is the means that produces the results you desire. One way is not inherently better than another 😊 Do you have any other questions we can assist you with?

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases