We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33612
    • 6 Posts
    I was having trouble getting Ditto to do what I wanted and posted a question in the General forum, but it didn’t go anywhere. So I figured I’d try getResources, but no luck. All I’m trying to do is display the value of a tv from several pages. Here’s how I tried and figure it out.

    Created...
    test-page
    test-template
    test-tv (input type: Text, iov: blank, default: blank, output: default)
    test-chunk

    I assigned test-tv to test-template, assigned test-template to test-page and entered blahblahblah for the tv value on test-page

    If I do a sanity check and put [[*test-tv]] on test-page is displays blahblahblah, so I know that much works

    Now to test getResource I made test-chunk and simply put...

    <p>[[+pagetitle]]</p>
    <p>[[+test-tv]]</p>

    Then put this on a separate page
    [[!getResources? &parents=`4` &includeTVs=`1` &tpl=`test-chunk`]]

    It works for the pagetitle but not test-tv.
    <p>Test Title</p>
    <p> </p>

    However I noticed if I break &tpl in the call (&tpl=`xtest-chunk`) it spits out the whole array.
    And the tv is listed in there.

    [tv.test-tv] => blahblahblah
    Any ideas what I am missing? Or what else I can try?

    Thanks!


    Apache 2.2.1
    MySQL 5.1.30
    PHP 5.2.9

    MODx 2.0.0-beta-5
    getresources 1.0.0
      • 28215
      • 4,149 Posts
      Your test chunk should be:

      <p>[[+pagetitle]]</p>
      <p>[[+tv.test-tv]]</p>
      


      getResources auto-prefixes TVs with the ’tv.’ prefix. You can change this by passing a different (or empty) prefix into the parameter &tvPrefix.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 33612
        • 6 Posts
        Oh for #@#! sake it’s right there in the array. Deduct 10 geek points...

        Thanks man! Been trying to figure that out for two days.
          • 3749
          • 24,544 Posts
          I filed a suggestion on Jira to have getResources default to an empty prefix. You’re adding weight to my case. wink

          BTW, the initial version of getResources ignored &tvPrefix=`’’`. Imagine how long *I* spent. grin
            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
            • 349
            • 76 Posts
            I vote for leaving the tvPrefix empty.

            BTW: Why do i have to use placeholders [[+ for my template variables instead of [[* in my chunk, when i use this snippet?
            Doesn´t make sense to me.
            • If it works the same as it does for Evo in this regard, it is because Ditto is applying the chunk to each document as it loops through the list and processes them. If you use [[*...]] that is referring to the variable for the current document; that is, the document MODx is processing, the one with the Ditto call on it. The chunks, on the other had, are being processed by Ditto. If you use [[*...]] it still tells MODx to get the value for the current document (the one with the Ditto call on it) while the placeholder [[+...]] tells Ditto to use the value for the document it is processing at that point in the loop.

              So [[*...]] is for MODx, and is for the actual current document MODx is processing, and [[+...]] is for Ditto (or Wayfinder or whatever snippet is being used) to use while looping through its list of documents to process.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
              • Quote from: aceman3000 at Apr 27, 2010, 08:05 AM

                I vote for leaving the tvPrefix empty.
                Create yourself a property set and set tvPrefix empty. Then use that property set everywhere you call getResources (or clone any new property sets from this one so they all have that setting). Or you can edit the default properties as long as you remember to modify it again the next time you upgrade the Snippet package. Or create your own version of getResources with a different name and different default properties.