I am using getResources to build a list of people on a page.
I set up TV’s to serve as Name, address, phone etc. I also have a bio TV.
Some people have a bio filled out, others do not. For the ones that do, I want to display a button "Read Bio".
My getResources call looks like:
[[!getResources? &parents=`[[*id]]` &showHidden=`1` &includeTVs=`1` &processTVs=`1` &tpl=`person_summary_tpl`]]
My person_summary_tpl looks like:
<div class="person-summary">
<img src="[[++site_url]][[+tv.person_photo]]" class="photo" width="100" alt="[[+tv.person_name]]" />
<p><strong>[[+tv.person_name]]</strong><br>
[[+tv.person_address]]<br>
[[+tv.person_city_state_zip]]<br>
<a href="mailto:[[+tv.person_email]]">[[+tv.person_email]]</a></p>
<p>[[!include? &file=`person_bio.php`]]</p>
<div class="clearall"> </div>
</div>
I had planned on writting a snippet to check if there was a value for the current person. The catch is, I’m not sure how to (or where to) grab the current document id that getResources is using to build it’s list. So, something like this would be my snippet:
[[!include? &file=`person_bio.php` &person_id=`getResourcesID would go here`]]
Then somehow in my person_bio.php file, I’d grab the ID. That way I could look up any TV value:
$resource_id = $modx->resource->get('id');
// check if there is a bio available
$person_bio = $modx->getObject('modTemplateVar',array('name'=>'person_bio')); // get the tv object
$person_bio_value = $person_bio->getValue($resource_id); // get the value from the tv
Or, maybe I’m making this entirely too difficult. Which, could be the case as well.