Hello,
I’m trying to figure out how to get the document id from the snippet inside the ditto template.
Here is my Ditto template:
<div class="ctv_thumb"><a href="[~[+id+]~]" class="[[Video_Style]]"><img src="/images/spacer.gif" border="0" width="150" height="125" alt="[+pagetitle+]"></a><img src="[+Video_Thumb_SML+]" width="150" height="100" border="0" alt="[+pagetitle+]" /><h1>[+pagetitle+]</h1></div>
The snippet: [[Video_Style]] contains the PHP which checks if you are currently on that particular document based on the parameter ’x’ in the url, ex:
http://domain.com/index.php?x=3456
<?php
$id = $modx->documentIdentifier;
$currentid = $_GET['x'];
if (($currentid != '$id') || ($currentclass == '')) {
$thumbclass = "ctv_link";
}
else {
$thumbclass = "ctv_link_active";
}
echo $thumbclass;
?>
since its being run at the document level i get the wrong id at this line: $id = $modx->documentIdentifier;
i search the forums and found this solution on how to grab a document id at the template level:
$docID = (isset($docID)) ? $docID : $modx->documentIdentifier;
$newID=$modx->getTemplateVarOutput('id',$docID);
For some reason it gives me back an ’array’.
Can anybody point out any obvious errors ?
Thanks!
Aleks