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.

Sort Entries by Categories?

July 21, 2010 3:28am

Subscribe [3]
  • #16 / Jul 23, 2010 2:09pm

    Brandon Jones

    5500 posts

    Hi Bmovie, try just the segment variable by itself in in the index template, to be sure we’re on the same page. So in your site’s index template:

    Segment 2 is {segment_2}

    Then visit the site at: domain.com/index.php/cars (should say segment 2 is blank)
    And visit it at: domain.com/index.php/cars/category (should say segment 2 is category)

    That works properly, yes?

  • #17 / Jul 23, 2010 4:09pm

    bmovie

    619 posts

    Hi Bmovie, try just the segment variable by itself in in the index template, to be sure we’re on the same page. So in your site’s index template:

    Segment 2 is {segment_2}

    Then visit the site at: domain.com/index.php/cars (should say segment 2 is blank)
    And visit it at: domain.com/index.php/cars/category (should say segment 2 is category)

    That works properly, yes?

    thanks, I do the test, and yes works like you say, see it:

    http://www.mysite.com/index.php/videos
    http://www.mysite.com/index.php/videos/category

    I think that test is for check if the segments are ok or? now whats the next step?

  • #18 / Jul 23, 2010 6:19pm

    Brandon Jones

    5500 posts

    OK, then try this code in that test template with the same two URLs:

    {if segment_2 == "category"}
       The entire weblog tag WITHOUT category_group
    {if:elseif segment_1 == "cars"} 
       The entire weblog tag with category_group
    {/if}
  • #19 / Jul 23, 2010 6:42pm

    bmovie

    619 posts

    OK, then try this code in that test template with the same two URLs:

    {if segment_2 == "category"}
       The entire weblog tag WITHOUT category_group
    {if:elseif segment_1 == "cars"} 
       The entire weblog tag with category_group
    {/if}

    That is! Brandon!

    I try in the past with if:elseif but now with your code example make the difference, I think in the past I don’t use entire weblog tag, now segments works! and sort entries by categories well

    Thanks a lot!!! I appreciate it!

    just curious why is not possible of this way:

    {if segment_2 == "category"}
    {exp:weblog:entries weblog="{my_weblog}" status="open" limit="18" disable="category_fields|member_data|trackbacks"}
    {if:elseif segment_1 == "cars"} 
    {exp:weblog:entries weblog="{my_weblog}" category_group="2" status="open" limit="18" disable="category_fields|member_data|trackbacks"}
    {/if}
    
    {switch="<ul class='item'>|<ul class='item'>|<ul class='item'>|<ul class='item'>|<ul class='item'>|<ul class='item-last'>"}
        <li><a href="http://{url_title_path=%22class=%22item-hover" title="{title}" class="item-hover"></a>{media_img}</li>
        <li class="h2"><a href="http://{url_title_path=">{exp:char_limit total="20"}{title}{/exp:char_limit}</a></li>
        <li class="h3">{categories}<a href="http://{path=">{category_name}</a>{/categories}</li>
    </ul>
    
    {paginate}
    <div id="page">
    {if previous_page}
        <a href="http://{auto_path}">« Anterior</a>
    {/if}                
    {pagination_links}
    {if next_page}
        <a href="http://{auto_path}">Siguiente »</a>
    {/if}
    </div>                
    {/paginate}
    
    {/exp:weblog:entries}
  • #20 / Jul 23, 2010 6:43pm

    bmovie

    619 posts

    -sorry… remove this please-

  • #21 / Jul 23, 2010 6:53pm

    Lisa Wess

    20502 posts

    You can’t separate opening entries tag as in your example:

    {if segment_2 == "category"}
    {exp:weblog:entries weblog="{my_weblog}" status="open" limit="18" disable="category_fields|member_data|trackbacks"}
    {if:elseif segment_1 == "cars"} 
    {exp:weblog:entries weblog="{my_weblog}" category_group="2" status="open" limit="18" disable="category_fields|member_data|trackbacks"}
    {/if}

    The entries tag must stay together in its entirety, as I mentioned in post #7.

    You’re up and running now?

  • #22 / Jul 23, 2010 6:58pm

    bmovie

    619 posts

    thank you Lisa! yeap now Im up and running! 😉

  • #23 / Jul 23, 2010 8:08pm

    Brandon Jones

    5500 posts

    Cool! Glad we could help.

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

ExpressionEngine News!

#eecms, #events, #releases