Hi All,
I have created a snippet that goes through a documents children and generates the ’pagetitle’ for each one can anyone tell me how i can incorporate the childrensTV into this loop? (im using tv to store a thumbnail image for each child).
heres my code so far:
$main_id = 2;
$current_id = $modx->documentObject[’id’];
$child = $modx->getDocumentChildren($main_id,1,0,"*","");
$code_out = ’’;
$count = 0;
foreach($child as $value){
if(!$value[’hidemenu’]){
if($value[’id’] == $current_id){
//$code_out .= $value[’menutitle’];
$code_out .= ’<p>’ . $value[’pagetitle’] . ’</p>’;
}else{
//$code_out .= $value[’menutitle’];
$code_out .= ’<p>’ . $value[’pagetitle’] . ’</p>’;
}
}
$count++;
}
echo $code_out;
Cheers, Ash
Try
$tvs = array(’tvname1’, ’tvname2’);
$rTv = $modx->getTemplateVarOutput($tvs,$docId);
access values using $rTv[’tvname1’] and $rTv[’tvname2’]
I would realy use Ditto for that, but you can try also this one:
<?php
$main_id = 2;
$current_id = $modx->documentObject['id'];
$tvidnames = array ('id', 'pagetitle', 'menutitle', 'yourTV');
$parentid = $main_id;
$child = $modx->getDocumentChildrenTVarOutput($parentid, $tvidnames, $published = 1, $docsort = "menuindex", $docsortdir = "ASC");
$code_out = '';
$count = 0;
foreach ($child as $value)
{
if (!$value['hidemenu'])
{
if ($value['id'] == $current_id)
{
//$code_out .= $value['menutitle'];
$code_out .= '<p>'.$value['pagetitle'].'</p>';
} else
{
//$code_out .= $value['menutitle'];
$code_out .= '<p>'.$value['pagetitle'].'</p>';
$code_out .= '<p>'.$value['yourTV'].'</p>';
}
}
$count++;
}
echo $code_out;
?>
Thanks for all your replies, works a treat.
Ash