We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8109
    • 128 Posts
    I have two problems. One is that I need to get the id of the parent of a document whose ID I have. In this context it works:

    [[!getResourceField?&id=`[[+contentID]]`&field=`parent`]]


    The ID is returned correctly. But when I nest this snippet in another, nothing is returned:

    [[!GetResources?
          &parents=`[[!getResourceField?&id=`[[+contentID]]`&field=`parent`]]`
          &tpl=`mfTaxonItemsTpl`
          &limit=`0`
          &depth=`0`
          &sortby=`{"pagetitle":"ASC"}`
          &showHidden=`1`
       ]] 


    I can verify that the get Roesources snippet returns an expected result if I don't use the placeholder value for the parents parameter. That's problem number one.

    As a workaround, because the content ID placeholder is set in a snippet I wrote, I thought I could simply set the parent as a placeholder in the same snippet. It's actually cleaner, in principle, but I can't get that to work either:

      $contentID = $modx -> parseChunk('mfMostRecentItemID');
       
       $modx -> setPlaceholder('contentID', $contentID);
    
       $taxonIDArr = $modx -> getParentIds($contentID);
       
       $modx -> setPlaceholder('taxonID', $taxonIDArr[0]);


    I can verify that the taxonIDArr is empty, and therefore the placeholder taxonID is not set, unless I use a value for the getParentIds method that is either a number or a variable set to a number. The variable I set by parsing a chunk does not give a result.

    Both avenues for solving this problem have run aground. I'd love help understanding either or both of them.

    Revo 2.0.8
      Revo 2.0.8-pl
      • 34118
      • 45 Posts
      drwagner

      This could be a Nested Tag problem. Using 2.1.2 I had a GetResources which contained a GetResourcesField. I had very odd problems. It wouldn't work unless I happened to have [[+id]] somewhere in the document/chunk.

      Not exactly the same circumstances but 2.1.3 has a Nested Tag fix. Upgraded to 2.1.3 and all worked. Try that.
        • 3749
        • 24,544 Posts
        You can also try this to prevent getting the cached value of the placeholder:


        [[!+contentID]]


        Also, make sure the tag for the snippet that sets the placeholder is above the getResources tag.

        Another way to go would be to use $modx->runSnippet() in your snippet to run getResources and either return the getResources return value or use it to set a placeholder.
          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