I have a powerful new snippet that PHP Dreams’s, Bill Wheeler wrote for us that is very cool. Here is the snippet code:

What It Does

Doc data allows you to reach out to any document within your MODx site and retrieve any placeholder and/or any Template Variable (TV) and then structure the output using a TPL chunk.

Usage

In our initial usage we have a directory which contains a large number of staff members. These pages use TVs and the ManagerManager snippet to present TV fields as forms.

Now, it is easy enough to present these pages as a directory, but I have another section of the site in which I need to present the staff’s data. In order to do this we set up a TV ([*staffTV*]) with Radio Options input type and placed the code below in the Input Option Values:

@EVAL return $modx->runSnippet('Ditto', array('startID' => '7','tpl'=>'@CODE ||[+title+]==[+id+]','sortDir'=>'asc'));

This allows us to populate a list of choices based on the staffing directory data in another section. The DocData snippet allows us to access all the data associated with those choices using the code below:

[[DocData? &doc=`[*staffTV*]` &tpl=`myTPL` ]]

My TPL chunk looks something like this (yes, it should work just fine with PHx):

<dl>

<dd>[+phx:input=`[*staffImage*]`:isnot=``:then=`<img src="[*staffImage*]"
alt="[+pagetitle+]" width="78" height="100" />`+]</dd>

<dt>

<b>[+pagetitle+]</b>[+phx:input=`[*staffPhone*]`:isnot=``:then=` &#9642; [*staffPhone*]`+]<br
/>

[+phx:input=`[*staffEmail*]`:isnot=``:then=`<a href="mailto:[*staffEmail*]"
title="[*staffEmail*]">[*staffEmail*]</a>`+]

</dt>

</dl>

This is just a fresh .1 version of this snippet, but at first glance it does seem to be a powerful tool. Thanks Bill!