Just a quick question...
Is it possible to add a utility to certain resources, so that on a specified date they will automatically move to a different container?
I’m thinking it would be ideal for a section of a website where certain events would appear under the appropriate section, depending on their start/end date or time.
Currently I use the getResources add-on to populate the two different sections (past and current events), although I can’t seem to find anything within the documentation that addresses this.
I’m also using Modx Revo 2.0.8
Thanks in advance.
It’s easy to move a resource to another location in code just by changing its ’parent’ resource field. The problem is how to get the code to execute.
You can relocate the page with a snippet just by changing its ’parent’ resource field but once the conditions are met to move the page, it wouldn’t move for the current visitor, only the visitor after that.
The code would look something like this:
<?php
/* test here to see if it's time to move the page and return if not */
$newParent='24';
$modx->resource->set('parent', $newParent);
$modx->resource->save();
Of course you could also just select the appropriate resources to show on each page based on their dates using getResources or your own snippet and leave the site organization alone.