Extension, Module

Developer
Supported

Member categories

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4

Back to this add-on's main page
View Other Add-ons From Yuri Salimovskiy

     

You must be logged in to post.

Order_by Issue in member_categories:categories tag

Bug Report

Tundra
Tundra

Hi

I have the following code using member categories to display a nav listing of categories assigned to a member:

<nav class="listing-nav clearfix">
 <
ul>
 
{exp:member_categories:categories category_group="5" order_by="order"}
  {if {parent_id} 
== 0}
   {if 
"{segment_3}" == "{category_id}"}<li class="active filter first">{if:else}<li class="filter first">{/if}<a href="{path='investor-login/folder/{category_id}'}">{category_name}</a></li>
  
{if:else}
   {if 
"{segment_3}" == "{category_id}"}<li class="active">{if:else}<li>{/if}<a href="{path='investor-login/folder/{category_id}'}">{category_name}</a></li>
  
{/if}
 {
/exp:member_categories:categories}
 
</ul>
</
nav

And categories setup like this:

Main Category 1
  Sub Category 1
  Sub Category 2

Main Category 2
  Sub Category 3
  Sub Category 4

However, when this out puts in the template the sort order is

Main Category 1

Main Category 2
  Sub Category 3
  Sub Category 4
  Sub Category 1
  Sub Category 2

I have used the recommended order_by=“order” parameter, which should honour the sort order of the categories, am I missing something?

I am running EE v.2.6.1

Thanks

Tundra

 

Yuri Salimovskiy
# 1
Developer
Yuri Salimovskiy

I think it has something to do with nesting order. Could be a bug, I need to check that. Would you mind posting the screenshot of your categories page in CP?

Tundra
# 2
Tundra

Tried to attach a file, but too big for this system (come on Devot-ee!!)

Is there an email address I can send it to?

Tundra
# 3
Tundra

I’ve also spotted these errors in the developer log, see attached.

Yuri Salimovskiy
# 4
Developer
Yuri Salimovskiy

Please email support@intoeetive.com

Mike Mella
# 5
Mike Mella

I have a similar issue. I want to order my categories alphabetically, regardless of their place in the nesting. Is this possible?

Yuri Salimovskiy
# 6
Developer
Yuri Salimovskiy

On front-end, if you omit order_by parameter, the categories will be sorted alphabetically. On backend, the categories are always displayed nested

Mike Mella
# 7
Mike Mella

Hmm. Doesn’t seem that way for me.

Attached is a shot of my categories, as well as their display on the front-end. Shouldn’t “Embedding a CSI Practice” come before “Prepare for Organizational Change”?

Here’s my code:

{exp:member_categories:categories category_group="{pr-smart-kits-category-group}" errors="off"}
    {if count 
== '1'}
    
<h2 class="section-header align-left">Smart Kits</h2>
    
{/if}
    
<a href="{path={pr-smart-kits-template-group}/category/{category_url_title}}" class="tile-parent tile">
<
div class="tile-text">{category_name}</div>
</
a>
    
{/exp:member_categories:categories} 
Yuri Salimovskiy
# 8
Developer
Yuri Salimovskiy

Ah, I see what you mean. The categories are being sorted by name WITHIN their parent.
I added new sort_by_tree=“no” config param - if specified, sorting will not respect category group and parents and will just sort by name or other param you specify.
Please update your files

Mike Mella
# 9
Mike Mella

Thanks for this, Yuri. I’ll have my client re-download it and send it to me.