Rendering in different sections based on asset metadata field


(Liam Nixon) #1

I am working on a project for my office where we have a series of event assets, each with a metadata schema that provides a field called event_end_date, which is in a date format.

My supervisor wants to have a page which has two sections, one for current events, one for upcoming events. Now, I could of course manually drag them between two page assets and render them that way, but my supervisor wants to automate this process and these events don’t actually end, they simply become future events again once they finish, ie. they repeat annually.

I was trying to figure out how I could go about this, I was thinking of having the default format asset under an asset listing perform a conditional check, something like:

%begin_event_end_date^lt:globals_date%
// This would become a future date, as it has ended
%else_asset%
// This would be a current event, as it still has an end date later than the current date.

For context, I know I need to be more specific in the conditional, to make sure that it checks if the end date is also < the last day of the year, otherwise I will be rendering in both current and future for events with an end date > the current date. This is just a quick example.

However, I can’t think of how the asset listing will be able to ‘assign’ these to a different place on the page, as my understanding is that in the page contents asset of the asset listing, I can only render the asset using %asset_listing%, which doesn’t really provide me an option to ‘position’ where it renders.

Let’s say the page contents file looks something like this:

<section>
  <strong><span>Current events</span></strong>
  %asset_listing%
</section>
<section>
  <strong><span>Future events</span></strong>
  %asset_listing%
</section> 

It doesn’t really work because I can only render the asset using the same keyword, it doesn’t conditionally check anything at this level.

Is there any way for me to have this functionality working? Sorry if it’s a simple question, I’m quite new to Squiz Matrix and am still learning how the keywords and assets interact.

Thank you for any help you can provide!


(Rhys) #2

Hi

I think you could do this with asset grouping

Add a new group level ‘at the top level’ of type ‘keyword’

Keyword asset_metadata_ event_end_date^maxchars:4

The “maxchars:4” modifier will set the group name to “2024” or “2025” so all events in that year should be grouped together


(Liam Nixon) #3

Hey there, thanks for the suggestion!

I will give it a try and will post back here if it gets it working, thanks for your help.


(Harinder Singh) #4

Are you dealing with a recurring event or a single calendar event? The “event_end_date” field seems to indicate a single calendar event to me. If so, are you manually setting up the new end date for the next year when the event expires?

Do you mean the current events that are happening today?


(Liam Nixon) #5

It’s a mix, the former employee configured the basis of a system that handles both recurring and single events as a single metadata field, with recurring events just having an end date set a while in the future, e.g., 10 years.

Not ideal, but as I am currently learning Matrix and our property receives high traffic volume, I am hesitant to completely refactor their work until I understand the inner workings of the CMS better.

I think, ideally, a current event would be this year, future event is next year. Once a current event has occurred, it would recategorize as a future event, if that makes sense?


(Harinder Singh) #6

Use “Calendar Events Search Page” instead Asset listing. you can pass the search parameter. This way you can use it twice for both listings