Hello everybody,
i have a little question.
I have a tv named pdf_path associate at product template.
How can check if this tv is null?
I have create this snippet but when i call it showed a parse error..
My snippet call:
[[check_pdf? ¶m1=`[+pdf_path+]` ]]
Snippet check_pdf:
<?php
if (empty($param1))
{}
else{
echo(’ <h2>DOWNLOAD</h2> ’);
echo(’ <div id="scheda_tecnica"> ’);
echo(’ <img src="image/icona_pdf.gif" /> ’);
echo(’<a target="_blank" href=’$param1’>Scheda tecnica</a>’);
echo(’ </br> ’);
echo(’ </div> ’);
?>
p.s. I use Modx evo 1.0.4
thx
Fabry
"Destiny is not a matter of chance, it's a matter of choice"
Quote from: bunk58 at Jan 19, 2011, 05:19 AM
Try something like this :
<?php
$id = (isset($id))? $id : $modx->documentIdentifier;
$tvName = (isset($tvName))? $tvName : 'pdf_path';
$output = '';
$data = $modx->getTemplateVarOutput(true, $id);
$tv = $data[''.$tvName.''];
if (!empty($tv)) {
$output .= '<h2>DOWNLOAD</h2>
<div id="scheda_tecnica">
<img src="image/icona_pdf.gif" />
<a target="_blank" href="'.$tv.'">Scheda tecnica</a>
</br>
</div>';
}
return $output;
?>
The snippet has two optional paramaters, &id=`nn` &tvName=`the-name-of-your=tv`
By default the current doc id is used and the tv with the name of pdf_path
Many Thx Bunk!! this work great!!!!
"Destiny is not a matter of chance, it's a matter of choice"