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]
  • #1 / Jul 21, 2010 3:28am

    bmovie

    619 posts

    hi,

    I have a template group cars
    I have a category group 1 cars
    Inside category group 1 cars, I have 3 categories bmw, toyota, audi

    so when I go to mysite.com/cars using this code:

    {exp:weblog:entries weblog="cars" category_group="1" status="open"}

    show JUST the entries that I assign to category group 1, GREAT!!!

    so whats the problem?

    when I go to mysite.com/cars/category/bmw/ DONT SORT the entries by category! why? because I need this:

    {exp:weblog:entries weblog="cars" status="open"}

    without category_group=“1” for works the sort entries by categores.

    how do it?

  • #2 / Jul 21, 2010 5:58am

    John Henry Donovan

    12339 posts

    Bmovie,

    What is your Category URL Indicator?
    CP Home ›  Admin ›  Weblog Administration ›  Global Weblog Preferences

  • #3 / Jul 21, 2010 2:22pm

    bmovie

    619 posts

    Bmovie,

    What is your Category URL Indicator?
    CP Home ›  Admin ›  Weblog Administration ›  Global Weblog Preferences

    thanks John, the indicator is “category”

    so I use the template “cars” for show entries of the category group 1, and when I try to sort by categories inside category group 1 like bmw etc… dont sort anything beacuse I need remove of the code “category_group=“1” so I think in use segments or is more simple to make that working?

    I mean something like this, for just use “category_group=“1” for /cars ad not for /cars/category the problem too is segment 1 cars works too for category beacuase category is inside cars… so the “if” dont work too.

    {exp:weblog:entries weblog="cars" {if segment_1 == "cars"} category_group="1" {/if} status="open"}

    please help my site dont sort anything at this moment

  • #4 / Jul 22, 2010 2:22am

    John Henry Donovan

    12339 posts

    Bmovie,

    You would be better off putting the conditional around the whole block.

    {if segment_1 == "cars"}
    {exp:weblog:entries weblog="cars" category_group="1" status="open"}  
    {/if} 
    
    {if segment_2 == "category"}
    {exp:weblog:entries weblog="cars" status="open"}  
    {/if}

    Let me know if that works for you

  • #5 / Jul 22, 2010 4:07am

    bmovie

    619 posts

    John thanks but dont work! why? is a thing that I never understand about segments… and is this:

    {if segment_1 == "cars"}
    hello moon!  
    {/if}
    {if segment_2 == "category"}
    hello sun!
    {/if}

    If I go to mysite.com/cars show “hello moon!” and if I go to mysite.com/cars/category show “hello moon!” too!!! not shot hello sun! why ??? beacuse category is inside cars so segments in almost all cases dont work beacuse dont respect the 2 3 4 5 positions if is inside other… you understand me?

    please help my site dont sort anything at this moment, I dont know how sort entries by categories, if is not with categories, whats the method?

  • #6 / Jul 22, 2010 6:18pm

    Brandon Jones

    5500 posts

    Bmovie,

    Keep in mind you can do this for the first piece of code:

    {if segment_1 == "cars" AND segment_2 == ""}
    hello moon!  
    {/if}
  • #7 / Jul 22, 2010 6:37pm

    bmovie

    619 posts

    thanks Brandon, but use “” let /cars entirely white screen, the point here is really how erase category_group=“2” when I go to /cars/category for make the sort by categories work… how? thanks

    this is my code, but dont work:

    {if segment_1 == "cars"}
        {exp:weblog:entries weblog="{my_weblog}" category_group="2" status="open"}
    {/if}
    {if segment_2 == "category"}
        {exp:weblog:entries weblog="{my_weblog}" status="open"}
    {/if}
  • #8 / Jul 22, 2010 10:51pm

    Lisa Wess

    20502 posts

    You can’t separate your opening entries tag like that.  You would need to encapsulate your entire entries tag:

    {if segment_1 == "cars"}
        {exp:weblog:entries weblog="{my_weblog}" category_group="2" status="open"}
    {title}
    {/exp:weblog:entries}
    {/if} 
    {if segment_2 == "category"}
        {exp:weblog:entries weblog="{my_weblog}" status="open"}
    {title}
    {/exp:weblog:entries}
    {/if}
  • #9 / Jul 22, 2010 11:20pm

    bmovie

    619 posts

    Lisa thanks I know that, my code is just an example, the point is that segments dont work! see I copy and simplify your code for you understand me:

    {if segment_1 == "cars"}
    HELLO MOON!
    {/if} 
    {if segment_2 == "category"}
    HELLO SUN!
    {/if}

    on browser results:
    mysite.com/cars result is: HELLO MOON!
    mysite.com/cars/category/ result is: HELLO MOON! (bad! I Need here result HELLO SUN!)

    thats the problem! segment_2 dont work! beacuse category is inside cars.

    and all that simple example code is for try to make “sort entries by categories” a simple ee thing, I explain that in my 1st post, please help, thanks

  • #10 / Jul 22, 2010 11:32pm

    Lisa Wess

    20502 posts

    What if you put just {segment_2} on the page? what does it echo?

  • #11 / Jul 22, 2010 11:41pm

    bmovie

    619 posts

    ok I put the real web site for you see it because my examples dont work:

    is you go to
    http://www.mysite.com/tv show the entries good! but if you go to
    http://www.mysite.com/tv/category/tv_entretenimiento/ dont sort anything!

    in the code of /tv I have this:

    {exp:weblog:entries weblog="tv" category_group="2" status="open" limit="18"}

    /tv load the entries assigned to category_group=“2”
    so when go to /category for make the sort work I need remove of the code category_group=“2”

    I dont know other way for sort entries… if you have a blog and have entries how suppose to make the sort? if you want sections with different themes? in my case /tv and /peliculas I use category groups for sort?

    you understand me now?

    really thanks

  • #12 / Jul 22, 2010 11:53pm

    Lisa Wess

    20502 posts

    Put {segment_2} in the template and view it - what gets rendered in its place?

  • #13 / Jul 23, 2010 12:03am

    bmovie

    619 posts

    Put {segment_2} in the template and view it - what gets rendered in its place?

    I put {segment_2} and render is nothing,

    I use this code:

    {assign_variable:my_weblog="media"}
    {assign_variable:my_template_group="tv"}
    
    {embed="_inc/master_doctype"}
    
    <body>
        
    
    {exp:weblog:entries weblog="{my_weblog}" category_group="1" status="open" limit="18" disable="category_fields|member_data|trackbacks"}
    
    {segment_2}
    
    {/exp:weblog:entries}
                                            
    </body>
    
    </html>

    and dont render anything… why?

  • #14 / Jul 23, 2010 3:48am

    John Henry Donovan

    12339 posts

    Bmovie,

    Put {segment_2} outside your weblog:entries tag for the moment and see if that works for you

  • #15 / Jul 23, 2010 3:55am

    bmovie

    619 posts

    Bmovie,

    Put {segment_2} outside your weblog:entries tag for the moment and see if that works for you

    {segment_2} outside… same thing… white screen… (I dont know why Lisa want that, for test something?)

    John you understand my problem?

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

ExpressionEngine News!

#eecms, #events, #releases