New Community Forums are coming. Watch this space for news.
Subscribe: RSS
  • Happy new year to all!

    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!

    This question has been answered by d.helfensteller. See the first response.

    [ed. note: d.helfensteller last edited this post 2 months, 2 weeks ago.]
    • Symlinks do not forward the user to the page they're linked to, instead they pull the content which often confuses things like getResources. Weblinks do forward the user, so you might do that instead.

      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;



        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
      • discuss.answer
        Firstly thank you very much for your efforts! And now I understand. I should have found out earlier...

        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]]`]]
        • I'm glad you got it sorted. smiley
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting