We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Combine results from two entries that are both using Grid

Development and Programming

Chris Wareham's avatar
Chris Wareham
40 posts
9 years ago
Chris Wareham's avatar Chris Wareham

Hello,

I am currently working on a website for a sports team and want to display recent results and upcoming fixtures for this team.

I can get it to pull back the correct data i think but the problem is that the matches and results are stored using Grid across multiple entries and even though i am using a limit=”3”, it is returning 3 results from each entry. Is there any way to combine all of the data from across all of the different entries and only return 3 results?

The EE code i have used for the 3 recent results is:

 {exp:channel:entries channel="league"}
  {league-game limit="3" orderby="match-date" sort="desc" search:match-date="<={current_time}"}
  <li>
   <a href="http://">_        <abbr title="{league-game:match-score}">{league-game:match-score}</abbr>_        <strong>{league-game:match-home-team} {league-game:match-home-score} - {league-game:match-away-score} {league-game:match-away-team}</strong>_        {league-game:match-date format="%d %M, %Y"}_       </a>
  </li>
  {/league-game}
 {/exp:channel:entries}

Has anyone come across a similar problem?

I can change the way this data is entered and not use Grid for matches, but this is quite a nice way for editors long term.

Chris

       
dmDev08's avatar
dmDev08
100 posts
9 years ago
dmDev08's avatar dmDev08

Why are league games not their own channel? Do they play games across leagues? If not, then you can handle this easily by making a different channel for each league and have the games be the entries.

Example:

Channel: Premier League Games

Channel: Liga BBVA Games

       
Chris Wareham's avatar
Chris Wareham
40 posts
9 years ago
Chris Wareham's avatar Chris Wareham

Thanks PM dmDev08 for taking a look. One of the main reasons for doing this was to try and make data entry & updating easy for editors.

There are 7 teams and various different tournaments throughout the year - the second team play in two leagues per year so i can imagine it getting a little bit messy after a couple of years.

It would be great if it could be done via Grid, but if not i will revert to using a separate channel for matches and associate them to a league another way such as categories.

Chris

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
9 years ago
Kevin Cupp's avatar Kevin Cupp

Hi Chris,

Sorry but Grid can’t aggregate across entries like that, so I think Relationships would be the way to go here. It may even be a good way to go for this content model in general.

       
Chris Wareham's avatar
Chris Wareham
40 posts
9 years ago
Chris Wareham's avatar Chris Wareham

Thank you Kevin for letting me know.

Would you then have two channels - leagues and matches and use then use the relationship field type to ‘import’ matches into the league?

Chris

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
9 years ago
Kevin Cupp's avatar Kevin Cupp

Yes Chris that sounds like a sane way to structure things.

       
Chris Wareham's avatar
Chris Wareham
40 posts
9 years ago
Chris Wareham's avatar Chris Wareham

Thanks Kevin and dmDev08 for your help.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.