0

I’ve started trying to figure out how relationships work and I have two channels (parentChannel and childChannel).

My data looks like this:

  • parentChannel - title - “Item Name”
  • childChannel - title - “2013 Item Name” , “2012 Item Name”, etc, etc

Within one of my templates, I would like to show some childChannel data, but I want to filter it to only the newest entry - in this case the 2013 entry.

How would I accomplish this? Should I be “filtering” my childChannel data by some other means than the title itself, such as a category?

All help is appreciated.

0

I can think of two ways of do this:

  1. to turn the parentChannel into a category group;
  2. to create a category or a field to save the year of the item name on childChannel;

To avoid duplicated data, I prefer the number 1.

0

I ended up solving this issue with the following code:

{channel_relationship orderby="title" sort="desc" limit="1"}

I create a relationship field between the parentChannel and childChannel called channel_relationship. Since the child fields all start with a year and I wanted to only display information from the newest year, I sorted all of the relationship entries by title, descending.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.