Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
Hi Users of CouchCMS

Following situation:
I'm building a website for our local scouting group and they're having different age-groups and each group has different leaders.

Now they're some activities they do with the other groups together, in which case I want to list all leaders of both groups.

So far so good.

Now my problem is that I can order those leaders by the group they're leading or the "order" field I created in the masterpage, but not both.

I looked it up in the pages documentary, but it doesn't seem to work.

The leaders are displayed.

Has anyone had similar problems? How do I solve it?

Thanks a lot!
- Helagon

Code: Select all
 
<cms:pages masterpage="data/leiter.php" custom_field="stufe = <cms:php>echo str_replace('|', ' , ' , '<cms:show stufe />');
</cms:php>" orderby='reihenfolge, stufe' order="asc">
       <cms:show k_page_title />
       <cms:php>
        if('<cms:show k_total_records />' > '<cms:show k_count />'){
             echo ',';
        }
       </cms:php>
</cms:pages>
I hope the following will help you:
1. advanced-tutorial/list-view.html
2. A working example of Notejam (Used in advanced turorials)
Regards,
GenXCoders
Image
where innovation meets technology

Thanks for trying to help, but it's not what I'm looking for ^^'

No Problem!

Could you please explain the use case in a detailed format.

Regards!
Image
where innovation meets technology

Maybe now my code will help to understand my problem ^^'

The way you have used the order by clause is perfectly fine. in the documentation it shows up as:
Multiple fields can be used together for sorting e.g.

<cms:pages masterpage='blog.php' orderby='modification_date, page_name'></cms:pages>


Now I suppose you have a relation field "stufe".

Can you please check what values of stufe are being displayed in the cms:pages tag.
I suppose the problem lies there, as multiple values may be displayed.
Image
where innovation meets technology

It's a dropdown.

I figured out the problem, but it seems rather illogical.

It seems like that pages orders the first field ascending, but the second field descending.



Unbenan3nt.PNG
reihenfolge, stufe
Unbenan3nt.PNG (3.49 KiB) Viewed 1249 times


Unbenannt.PNG
stufe, reihenfolge
Unbenannt.PNG (3.31 KiB) Viewed 1249 times

It seems like that pages orders the first field ascending, but the second field descending.

I think that is because your code is missing the order directive for the second field (and hence defaults to 'desc')
Code: Select all
 orderby='reihenfolge, stufe' order="asc"

As explained in the docs (https://docs.couchcms.com/tags-referenc ... html#order), if multiple fields have been used in the orderby parameter, separate sort orders can be set for each of the orderby field e.g. as follows -
Code: Select all
 orderby='reihenfolge, stufe' order="asc, asc"

Hope this helps.

Thank you very much KK!

That solved the issue!

You are welcome :)
10 posts Page 1 of 1