Skip Navigation

[Resolved] Sorting my view

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by Nigel 1 year, 10 months ago.

Assisted by: Nigel.

Author
Posts
#2648097
courses-and-conferences-repeated-fields-child-view.png
courses-and-conferences-parent-view.png
not-sorting-correctly.png
expected-sort-order.png

Tell us what you are trying to do?

I would like it sort by course date in ascending order then by post title as a secondary should something have the same date.
Any content that does not have an available course offering ( course date and location ) should then be displayed after everything that does have an available course offering ( course date and location ).

Is there any documentation that you are following?
Nothing that I have found so far.

Is there a similar example that we can see?
I have attached a screenshot of how I expect my content to by sorted by. As well as the current output of my content. And screenshots of both views that are outputting my content.

What is the link to your site?
hidden link

#2648201

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

Can you clarify how your data is set up?

It looks like you are using repeatable field groups, possibly other post relationships, and to answer your question about ordering it would be helpful to understand the structure of your data and how that is being output.

#2649141

This is a view displaying one content type called "courses-conferences". We are displaying a repeatable field group which contains the date and location. All the other fields are the post-title and and an edit button for that piece of content for admins. If there are no offerings then it should display a string that says there are no offering available.

Does that information help answer your question?

The aim or goal for this view is to output all content that is published and display it in this custom order for users. So that they can easily find all available courses or conferences that have current offerings.

#2649209

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Thanks for clarifying.

The problem is that you are trying to order the courses-conferences posts by a field which doesn't "belong" to them, i.e. the course date field which is part of the repeatable field group assigned to the courses-conferences posts.

In terms of the implementation, repeatable field groups are based on posts which act as a container for the fields, and these posts are related (child) posts of the courses-conferences post they "belong" to.

The only way you would be able to order based on this field is to effectively create a copy of that field that does belong directly to the courses-conferences posts. (Given that, by its nature, there may be several values for the course date field of the repeatable field group, you might have a custom field on your courses-conferences posts that records the first future such course date, which is the value you would want to order by.)

These could be manually entered, or you could add some code to make it automatic. How are users entering the data? In the back end or the front end?

#2649513

I se that makes since. They are being created by a custom plugin I built which pulls in a Drupal XML feed from one of our other sites. They should be being created automatically if all is going well with my plugin.

#2649643

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Right. So can you add a line or two to your plugin to add the value of the course date field directly to the parent post (with some logic if there are multiple values to only add the first such future value)?

#2657101

I ended up just writing everything in a custom plugin instead but thank you for the assistance.

Lindsay