Plugin

Developer
Supported

EE 1
EE 2
Child Categories

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

     

You must be logged in to post.

Custom sorting of entries

General

Andy Kelly
Andy Kelly

Forgive my rushing into this question, but I’ve written this post several times and it keeps getting deleted when clicking submit.

Great plug-in, thanks for the efforts.

I desperately need to sort my entries not on date or title, but on a custom field. Will this ever be possible?
I’ve tried working around things by omitting the entries loop, and making a channel:entries call in the child_categories loop. But it doesn’t seem possible to pass child_category_id to the category parameter.

Any hints?

Andy

Laisvunas
# 1
Developer
Laisvunas

I’ve tried working around things by omitting the entries loop, and making a channel:entries call in the child_categories loop. But it doesn’t seem possible to pass child_category_id to the category parameter.

This is possible, just add parameter

parse="inward" 

to exp:child_categories tag.

Andy Kelly
# 2
Andy Kelly

Oh, very excellent!

Thanks so much, for your quick reply and this plug-in.

Andy

Austmel
# 3
Austmel

Hi,

I have the same issue and can’t work out what i need to change in my code to sort by a low reorder custom field. If i put my channel entries call outside the {entries_start} tag i do not get any results.

Here is my code

{exp:child_categories channel="products" parent="21" child_categories_sort_by="name" child_categories_sort_direction="asc" entries_sort_by="title" entries_sort_direction="asc" show_empty="no" entries_limit="none" parse="inward"}
{parent_category_start}
{if 
'{parent_category_id}' =="21"}
<p><h5>{parent_category_name}</h5></p>
{/if}
{parent_category_end}

{child_category_start}
{if 
'{child_category_id}' =="60"}
<h4>{child_category_name}</h4>
{/if}
{child_category_end}

{entries_wrapper_top_start}{entries_wrapper_top_end}
{entries_start}

{exp
:channel:entries channel="products" category="60" entry_id="{entry_id}" dynamic="no" orderby="product_order" sort="asc"}
{sn_product_summary_simple}
{
/exp:channel:entries}

{entries_end}
{entries_wrapper_bottom_start}{entries_wrapper_bottom_end}
{
/exp:child_categories} 

Any help would be appreciated.

cheers,

Ben.

Laisvunas
# 4
Developer
Laisvunas

Hi,

If you need to display several entries using exp:channel:entries tag, then why you added

entry_id="{entry_id}" 

parameter?

Austmel
# 5
Austmel

Hi,

If i remove

entry_id="{entry_id}" 
then i get multiple identical entry results. When i use
entry_id="{entry_id}" 

i get 1 set of unique entry results.

Ben.

Laisvunas
# 6
Developer
Laisvunas

Hi,

Instead of using

entry_id="{entry_id}" 

Try this:

{exp:child_categories channel="products" parent="21" child_categories_sort_by="name" child_categories_sort_direction="asc" entries_sort_by="title" entries_sort_direction="asc" show_empty="no" entries_limit="none" parse="inward"}
{parent_category_start}
{if 
'{parent_category_id}' =="21"}
<p><h5>{parent_category_name}</h5></p>
{/if}
{parent_category_end}

{child_category_start}
{if 
'{child_category_id}' =="60"}
<h4>{child_category_name}</h4>
{/if}
{child_category_end}

{entries_wrapper_top_start}{entries_wrapper_top_end}
{entries_start}

{if 
"{child_categories_entry_count}" == "1"}
{exp
:channel:entries channel="products" category="{child_category_id}" dynamic="no" orderby="product_order" sort="asc" limit="10"}
{sn_product_summary_simple}
{
/exp:channel:entries}
{
/if}

{entries_end}
{entries_wrapper_bottom_start}{entries_wrapper_bottom_end}
{
/exp:child_categories} 
Austmel
# 7
Austmel

Hi,

That code did not work either i got 3 identical entries but with incorrect titles on them.

Before my code i am using a conditional

{if:elseif '{segment_3}' == "steam_class_6"

I’m not sure if that is causing an issue?

thanks again for your help in trying to get to the bottom of this i really appreciate your time.

Ben.

Laisvunas
# 8
Developer
Laisvunas

Hi,

Which part of the code outputs wrong results?

Is it this part of the code or some other?

{entries_start}

{if 
"{child_categories_entry_count}" == "1"}
{exp
:channel:entries channel="products" category="{child_category_id}" dynamic="no" orderby="product_order" sort="asc" limit="10"}
{sn_product_summary_simple}
{
/exp:channel:entries}
{
/if}

{entries_end} 

If it is this part of the code, then does this code output what you expect?

{exp:channel:entries channel="products" category="60" dynamic="no" orderby="product_order" sort="asc" limit="10"}
{sn_product_summary_simple}
{
/exp:channel:entries} 
Austmel
# 9
Austmel

Hi,

Using your suggested code

{exp:channel:entries channel="products" category="60" dynamic="no" orderby="product_order" sort="asc" limit="10"}
{sn_product_summary_simple}
{
/exp:channel:entries} 

Displayed is the correct entries in the correct order but the title for each entry is not correct and i get the entries duplicated with each duplicated set of entries showing a different incorrect title. 2 of the incorrect titles are from a different category.

This is the result:

Category 2 title

Entry 1 - incorrect title
Entry 2 - incorrect title
Entry 3 - incorrect title
Entry 4 - incorrect title
Entry 5 - incorrect title

Entry 1 - different incorrect title
Entry 2 - different incorrect title
Entry 3 - different incorrect title
Entry 4 - different incorrect title
Entry 5 - different incorrect title

Category 3 title

Entry 1 - another different incorrect title
Entry 2 - another different incorrect title
Entry 3 - another different incorrect title
Entry 4 - another different incorrect title
Entry 5 - another different incorrect title

——————————————————————————————————————-

My categories are set like this:
Category 1
——-Category 2 - Parent with ID 21
————-Category 3 - Child with ID 60

The results should show

Title Category 2
Title category 3
Entry 1
Entry 2
Entry 3
Entry 4
Entry 5

With entries ordered by low reorder field.

Any other ideas?

cheers,

Ben.

Austmel
# 10
Austmel

If i remove the

parse="inward" 

parameter i get the same set of incorrect result but the titles of each entry is displayed correctly.

Laisvunas
# 11
Developer
Laisvunas

My categories are set like this:
Category 1
——-Category 2 - Parent with ID 21
————-Category 3 - Child with ID 60

The results should show

Title Category 2
Title category 3
Entry 1
Entry 2
Entry 3
Entry 4
Entry 5

With entries ordered by low reorder field.

Your code should be like this:

{exp:child_categories parent="21" child_categories_sort_by="name" child_categories_sort_direction="asc"   show_empty="no" parse="inward"}

{parent_category_start}
<h1>{parent_category_name}</h1>
{parent_category_end}

{child_category_start}
<h2>{child_category_name}</h2>
{exp:channel:entries channel="products" category="{child_category_id}" dynamic="no" orderby="product_order" sort="asc" limit="10"}
<h3>{title}</h3>
<
p>{sn_product_summary_simple}</p>
{/exp:channel:entries}
{child_category_end}

{
/exp:child_categories} 
Austmel
# 12
Austmel

Hi,

Thank you very much that has fixed my problems :)

I really appreciate your time in helping me solve my mistakes - excellent support!

thanks,

Ben.