Search Page or Asset Listing based on metadata date


(Tim Davison) #1

Hi all


Was wondering if anyone knew if it was possible to get a search page or asset listing that will show all pages in a site that have a metadata date field that is older than today's date?



Example, we have a metadata field DC.Date.valid used to store the date the asset should expire. I was wanting to create a page that will list all assets that have expired (ie DC.Date.valid < today's date).



I can create a Search page that lists all assets based on a metadata field, and that works great, but I can only make it work for a set value (ie metadata field = my value).



I can also create an Asset Listing and sort the pages by DC.Date.valid, but this returns every page in the site. I can use css and js to hide the ones I don't want, but our site has 2000+ pages so the asset listing takes a long time to come back, even times out a lot of the time.



Not sure if it even is possible, but very keen to know if anyone else has faced this issue and solved it.



Thanks


(Tim Mcqueen) #2

Hi Tim,


I understand the problem here with waiting for load times - we have over 16,000 pages among all our sites and sub-sites.



Our system is that when a new asset is created, we have a trigger that sets a Future Status of “up for review” in x-number of months/days. Then I create asset listing to show things that are “up for review”.



For things that need to be reviewed before the time period set by the trigger (such as events) we just add a future status manually at the time we create it.





How is DC.date.valid set? is it an automatic computer-generated time? Based on how long a validity? (i.e. could it be replaced with a trigger setting “up for review” or another status?)





A similar idea to what you need, but for a different purpose is something I am trying to work out myself. I am trying to make a listing that is (essentially) a Whats New listing (in that I can customise it 100% layout/display, and select a time range), but rather than use the presets of Created date, Updated date, Published date, etc… use a date I have set in the metadata (- same concept as you) for the value it looks at.

However, this I want so that I can sort “past events” from Upcoming Events (calendar asset)



I’ll let you know if I come up with something. ;)


(Tim Davison) #3

Thanks Lightning

 

DC.Date.valid is set by the system, by a trigger when assets are published.

 

I actually did solve this but in a rather roundabout way.  I added another metadata field in our schema called System.Expired, value can be Yes|No.  Then I created a metadata Time Trigger that looks at DC.Date.valid.  The trigger figures out when it's past DC.Date.valid, and then sets System.Expired field to Yes.  Then, to show all expired pages it's simply a search page that matches on System.Expired = "Yes".

 

That said, you probably want to hide the System.Expired field from authors, otherwise they can just un-expire the page.  Not a huge risk since the trigger will kick in again next time cron job runs and re-expire it, but then authors could change the expiry date as well (depends how aggressive your authors are).  We use EES so hiding metadata fields from authors was a whole new kettle of fish, but we did it.  Actually works quite nice now.  Site admins have a page with the list of expired assets, and can chase authors individually when their pages expire, and it allows us to catch the assets that fall through the cracks using future statuses, etc.  We found a couple hundred that were very old and were outside the review cycle.


(Smallwooda) #4

Hi Tim,

 

I think this post is really going to help me break the back of loads of Matrix limitations that I have. I can't believe that there's an 'upcoming events' list but no native way to show 'previous events'.

 

I understand what you've done above but can you explain how you've set the initial trigger. I guess the DC.Date.valid is set to equal the Single Calendar Event end date?

 

Can you tell me the event, condition and action?


(Nic Hubbard) #5

I think this post is really going to help me break the back of loads of Matrix limitations that I have. I can't believe that there's an 'upcoming events' list but no native way to show 'previous events'.

 

You can use a Rolling Calendar Page asset to show events in the past. You can even customize the value for this by days, months, etc.


(Smallwooda) #6

Hi Nic, 

 

That's great - I've got it working but is there anyway to have it in descending order?

 

http://www.westminster.ac.uk/ecocities/events/events-archive2/_nocache

 

(PS - I'm getting the app this month, hope it's going well!)


(Nic Hubbard) #7

Hi Nic, 

 

That's great - I've got it working but is there anyway to have it in descending order?

 

http://www.westminster.ac.uk/ecocities/events/events-archive2/_nocache

 

(PS - I'm getting the app this month, hope it's going well!)

 

No, it doesn't look like you can. If you are able to move the events that are in the past in their own location, you could use an Asset Listing, sorting by start date, and then have it in descending order.

 

Awesome about the app! Things are going well. We are hoping 1.0.4 will get approved soon, with 1.1 coming in a month or so!


(Tim Davison) #8

Hi Leg3nd

 

I know there's been a few posts since, but wanted to answer your question.

 

I don't actually use any assets to do with the Calendar types.  The date fields are just simple metadata date fields.  So the date can be anything, set by trigger or manually changed - whatever you want.  Then the metadata time trigger just checks that date field to whatever is currently set.  As soon as the current date/time goes past what's specified in that field it sets another metadata field to Yes (a simple metadata select field, options Yes|No).

 

Trigger to set expiry is (we have 2 fields that are relevant here, DC.date.valid and System.Expiry):

Events:

- Metadata time

 

Conditions:

- [usual limiting, eg by root node and asset type, etc]

- Metadata Time: field with expired value = DC.date.valid

- Metadata Value: System.Expired = No (not sure if we need this, stops the cron jon acting on assets already expired, I figured it was more efficient this way).

 

Actions:

Set Metadata Value: System.Expired = Yes

 

So, once expired an asset should not be checked (since the condition only looks at non-expired).

 

Then, as part of the publishing process, we have another trigger that sets the DC.data.valid field to some time in the future, and sets System.Expired back to No.

 

Hope that makes sense.  I know it may not be exactly what you are looking for as Nic seems to have given you some helpful answers.  Let me know if there's anything else I can help clarify.


(Smallwooda) #9

No, it doesn't look like you can. If you are able to move the events that are in the past in their own location, you could use an Asset Listing, sorting by start date, and then have it in descending order.

 

Awesome about the app! Things are going well. We are hoping 1.0.4 will get approved soon, with 1.1 coming in a month or so!

 

Hi Nic,

 

Thanks for that but I don't want to move assets around due to SEO purposes. After the event has gained a ranking, I want to retain it so I don't want to create new URLS.

 

Cheers Tim, I'll put this idea to the team and see what they think.

 

Andi


(Nic Hubbard) #10

Hi Nic,

 

Thanks for that but I don't want to move assets around due to SEO purposes. After the event has gained a ranking, I want to retain it so I don't want to create new URLS.

 

Cheers Tim, I'll put this idea to the team and see what they think.

 

Andi

 

Well, but you don't have to change the URLs. You just create a new link to an "Archived" folder. Then, remove the webpath for that folder which makes it so it doesn't get a URL for that lineage. That way, you have a way of holding those archived events, but they still keep their old URL. Then you can use the Asset Listing method that I mentioned above.