<![CDATA[ Symlink cache / getResources:ifempty - My Forums]]> https://forums.modx.com/thread/?thread=104765 <![CDATA[Symlink cache / getResources:ifempty]]> https://forums.modx.com/thread/104765/symlink-cache-getresources-ifempty#dis-post-563411
I have an issue with a symlink-scenario, maybe someone can assist me. On my customers website the resource-structure is as follows:

- Speakers [3] (speakers.html - always symlinked to the latest year = 2019)
--- 2018 [10] (speakers/2018/)
--- 2019 [49] (speakers/2019/)

Each year contains several resources/speakers like

- /speakers/2018/speakername1.html
- /speakers/2018/speakername2.html
- /speakers/2018/speakername3.html
- /speakers/2019/speakername1.html
- /speakers/2019/speakername2.html
- /speakers/2019/speakername3.html
- ...


The template contains a getResources-call like follows, to show whether a list of speakers, or a "coming soon"-chunk :

[[getResources:ifempty=`[[$comingsoon]]`? 
   &parents=`[[*id]]`
   &context=`web`
   &depth=`0`
   &hideContainers=`1`
   &showHidden=`1`
   &limit=`0`
   &sortby=`menuindex`
   &sortdir=`ASC`
   &includeTVs=`1`
   &processTVs=`1`
   &tpl=`tpl_item_speaker`
]]



Now my issue happens as follows

  • I clear MODX-cache manually or by editing/saving a resource
  • I call url /speakers.html (symlinked to speakers/2019/) but it will show the "coming soon"-chunk, even when resources exist and should be listed by getResources

To overcome this issue I am forced to

  • call /speakers/2019/ always first after cache has been cleared by any event or action
  • then /speakers.html will show the resources-list of /speakers/2019/ like it should

I am not sure how to solve this issue, can someone maybe give me a hint?


Cheers!]]>
d.helfensteller Jan 02, 2019, 07:47 AM https://forums.modx.com/thread/104765/symlink-cache-getresources-ifempty#dis-post-563411
<![CDATA[Re: Symlink cache / getResources:ifempty]]> https://forums.modx.com/thread/104765/symlink-cache-getresources-ifempty#dis-post-563426
]]>
BobRay Jan 03, 2019, 10:09 PM https://forums.modx.com/thread/104765/symlink-cache-getresources-ifempty#dis-post-563426
<![CDATA[Re: Symlink cache / getResources:ifempty (Best Answer)]]> https://forums.modx.com/thread/104765/symlink-cache-getresources-ifempty#dis-post-563422
When I called the symlink directly, the symlink´s own [[*id]] (3) was given to getRecources, not the target-id (49). So the result was empty. My solution is

[[getResources:ifempty=`[[$comingsoon]]`? 
   &parents=`[[*id:is=`3`:then=`49`:else=`[[*id]]`]]`
   ...


means

[[*id:is=`speakers.html`:then=`speakers/2019/`:else=`[[*id]]`]]
]]>
d.helfensteller Jan 03, 2019, 03:10 PM https://forums.modx.com/thread/104765/symlink-cache-getresources-ifempty#dis-post-563422
<![CDATA[Re: Symlink cache / getResources:ifempty]]> https://forums.modx.com/thread/104765/symlink-cache-getresources-ifempty#dis-post-563415
FWIW, I would just put a snippet on the page that automatically forwards the user to the correct year page. The code below assumes that '2018' and '2019' are the actual aliases. That way, you don't have to change anything at all on New Year's Eve:

[[!ForwardToYear]]



/* ForwardToYear snippet (untested) */
$year = date("Y");
$doc = $modx->getObject('modResource', array(alias =>$year));
if ($doc) {
   $url = $modx->makeUrl($doc->get('id'), "", "", "full");
   $modx->sendRedirect($url);
}
return;



]]>
BobRay Jan 02, 2019, 08:05 PM https://forums.modx.com/thread/104765/symlink-cache-getresources-ifempty#dis-post-563415