EEConf 2024 is around the corner! EEConf 2024
This would indeed make development with EE much more straightforward. Is there a specific platform or system you are referring to when you mention “EE”? iq test
Hi and sorry for this late response!
The project that brought this to mind is a portfolio gallery for an interior designer.
They wanted to list their portfolios by year, but they do not always publish new portfolios in the year the project was completed. So, we added a “year” input in their publish form which is great for listing the year, but difficult to use for grouping / listing the entries under a year heading.
Asking them to use the Entry Date input as the year designation caused other issues and seemed clunky to have the client use that method.
This may already be resolved by the additional functionality in EE7 (structure, pro search). That site was developed in EE6.
If there is a simple way to accomplish this in EE7, I’d love some basic guidance as we come across this issue often-ish.
Ideally you’d use the Entry date, if you can get them to do that you could use the date_heading tag to automatically group entries by day, week, month or year. https://docs.expressionengine.com/latest/channels/entries.html#date_heading
Hi Rob, Thank you very much! The date_heading tag. - I had not come across that one before. Very useful.
I have another, more complex example of what I am referencing in my post:
For a school’s website, they have about 14 sports students can participate in. Each sport is broken down into teams divided by grade. Example: Baseball (one sport) has 3 teams: Middle School Baseball, Junior Baseball and Varsity Baseball.
I need to create a sidebar nav for these teams. As you can imagine the list is very long. So, I want to use collapse panels so the sidebar will display all Sports. When a sport name, like Baseball, is clicked, the collapse will expand to show the three baseball teams. - Repeated for each sport.
I have tried using Categories with not much luck.
I have 2 channels setup. One holds the Sport names (Baseball, Football etc…) and one holds Team content. In the Team channel I have a select field that pulls values from the Sports channel. So the Middle School Baseball entry will have “Baseball” selected as the team sport.
After trying a few methods, I cannot create a conditional or other method to select the first Team returned under Baseball and insert the opening div of the collapse panel, then likewise select the last Team under Baseball and insert the closing div tag for the collapse.
Would you have any guidance for that?
The filtering system in pro variables seems to require a page refresh which I am trying to avoid.
A quick and dirty way to do this might be to utilise the details
tag to give you collapsed content, not ideal sematically but it will give you a solution:
Assuming team_related_sport
if the field you related teams to sports with (a Relationship field).
<h2>Sports</h2>
{exp:channel:entries channel="sports"}
<details>
<summary>{title}</summary>
<ul>
{team_related_sport}
<li><a href="http://YOUR_LINK">{team_related_sport:title}</a></li>
{/team_related_sport}
</ul>
</details>
{/exp:channel:entries}
That will give you a list of sports, where each sport has the teams below it.
Rob, That is great. Thank you very much!
In writing out & discussing with you I also came across the parents tag pair for relationship fields. You are correct, relationships is better for this use than my original select field. In case it helps anyone using Bootstrap Collapse, I’ve copied my code below. Both your version, using <details> and this will get the job done.
{exp:channel:entries channel="sports" orderby="title" sort="asc"}
<h5 type="button" data-bs-toggle="collapse" data-bs-target="#{url_title}" aria-expanded="false">{title}</h5>
{parents field="sport_relationships"}
{if parents:count == 1}<div id="{url_title}" class="collapse">{/if}
<a href="http://THE_LINK">{parents:title}</a>{if parents:count != parents:total_results}\<br\>{/if}
{if parents:count == parents:total_results}</div>{/if}
{/parents}
{/exp:channel:entries}
Thanks again!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.