Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Different sort children for different pages?


Go to End


686 Views

Avatar
Emeloh

Community Member, 2 Posts

13 June 2013 at 4:19pm

Edited: 17/06/2013 2:20pm

The general situation:

- I have a list of topics which are assigned people (or people are assigned topics - under a man_many relationship), which are broken up into categories (I have CategoryHolder that groups all of the topics of and a Category page).

CategoryHolder is parent to Category is parent to Topic.

I pull this information onto my CategoryHolder page like this:
<% loop Children %>
<h3>$Title</h3> <!-- Category title -->
<br>
<div id="wrapper2">
<% loop Children %>
<li><a href="$Link" title="$Title">$Title</a>$Intro </li><!-- Topics for this category -->
<% end_loop %>

This is great! Exactly what I want for this page.

But now, they want to change it so that on the individual people pages, Instead of having the topics sorted alphabetically within their categories they want all the topics assigned to that person listed alphabetically overall.

Is there a way that I can do this?

So Example

On the categoryholderpage page I have:

History
- Ancient
- Middle Ages
- Post Modern

Science:
- Biology
- Chemistry
- Physics

But I want on the peoplepage, for the user:

Prof FakeName
Topics:
- Ancient
- Biology
- Post Modern

Instead of:

Prof FakeName
Topics:
- Ancient
- Post Modern
- Biology

I'm really not sure how to fix this, any suggestions would be greatly appreciated.

ETA: I found a fix to sort by titles on the people page:

<% control Topics.sort(Title) %>
<p> <a href="$Link" title="$Title">$Title</a>
<% end_control %>