We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22797
    • 134 Posts
    Is it true that Ditto is unable to retrieve the inherited values of parent template variables, as suggested in this thread (and others): http://modxcms.com/forums/index.php/topic,5773 ? (My own testing shows this to be the case, unfortunately sad )

    I structured my data around the assumption that I’d be able to use Ditto to print the data for the specific page plus any inherited values (from TVs with @INHERIT), but if I can’t do that, I’m not sure what to do instead. Is there a solution or hack yet?
      • 18397
      • 3,250 Posts
      Unless the MODx API has been fixed since 0.9.6 (I’m not sure...) it is not currently possible. It would be great if you could create a Ditto ticket for this (link in my signature) so that it can be put on the roadmap.
        • 17883
        • 1,039 Posts
        I´m not quite sure, but perhaps you can solve this problem with phx (&phx=`1`) in your ditto call and the getfield snippet.

        Since Ditto can´t handle nested calls in phx you can use the input handler. Could be like this in your ditto chunk:

        <div class="enttry">
        <h3>Item Title: [+pagetitle+]</h3>
        <h4>Category: [+phx:input=`[[getfield?parent=`1` &docid=`[+id+]` &parentLevel=`1` &field=`yourTV`]]`+]</h4>
        [+content+]
        </div>


        where "yourTV" is the name of the TV you want to get the parents content from.

        Not tested at all, but perhaps a solution.


          • 22797
          • 134 Posts
          Your suggestion of using PHx and getfield seems like a good one, but for some reason I can’t get version 1.3 of getfield to work at all on my system, and the previous version 1.2.2 only retrieves the standard document fields (id, pagetitle, longtitle, etc.), and not any of the custom template variables. I read in the support forum for getfield that there have been some PHP version incompatibilities, and the snippet hasn’t been updated in about a year, so that may be the root of the problem.

          I’m using MODx 0.9.6 and PHP version 5.1.4. I don’t have control over the PHP version, unfortunately.

          I’m sure the code could be rewritten to work, but I’m probably not the best person to attempt that, in terms of the limitations of my PHP expertise.
            • 7231
            • 4,205 Posts
            It works on my server no problem, we have php 5.2.4 and I have used it on php 4 as well no problem. Are you getting an error message? Try it with the call uncached by using [! !] that often resolves snippet issues.

            [!getfield?parent=`1` &docid=`[+id+]` &parentLevel=`1` &field=`yourTV`!]
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]