Sorry for stupid question, but i cant figure out how to get a TV value in a snippet
Currently i have this but i doesnt return anything. The TV name: SKIN_HS_image
<?php
$tv = $modx->getTemplateVarOutput("*", 124, 1);
$results = $tv["SKIN_HS_image"];
echo "tv:".$results."";
?>
Thanks,
Aleks
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
Try running [tt]die(var_dump($tv));[/tt] just after you get the output and post your results.
should this retunr the contents of the TV ?
<?php
$tv = $modx->getTemplateVarOutput('SKIN_HS_image', 124, 1);
echo $tv;
?>
i get ’Array’
thanks,
Aleks
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
this is what i get:
tv:array(39) { ["ThumbIMG"]=> string(0) "" ["SKIN_HS_Image"]=> string(66) "http://www.domain.com:8383/assets/images/skin/hs_blackdiamond.jpg" ["alias"]=> string(13) "BLACK-DIAMOND" ["cacheable"]=> string(1) "0" ["content"]=> string(396) "
We're ready to retire the word "bling" but ice is forever. These luxurious pieces are sure to start a chain reaction. SorryтАФmodel JESSICA WHITE not included.
Styling by Anoma Whittaker. Photographs by Matt Doyle.
{{Skin_Galleries}}
{{Skin_Galleries_Nav}}
[[test]]" ["contentType"]=> string(9) "text/html" ["content_dispo"]=> string(1) "0" ["createdby"]=> string(1) "2" ["createdon"]=> string(10) "1175291455" ["deleted"]=> string(1) "0" ["deletedby"]=> string(1) "0" ["deletedon"]=> string(1) "0" ["description"]=> string(28) "Black Diamond: Jessica White" ["donthit"]=> string(1) "0" ["editedby"]=> string(1) "1" ["editedon"]=> string(10) "1176752783" ["haskeywords"]=> string(1) "0" ["hasmetatags"]=> string(1) "0" ["hidemenu"]=> string(1) "0" ["id"]=> string(3) "124" ["introtext"]=> string(0) "" ["isfolder"]=> string(1) "0" ["link_attributes"]=> string(0) "" ["longtitle"]=> string(28) "Black Diamond: Jessica White" ["menuindex"]=> string(1) "7" ["menutitle"]=> string(13) "BLACK DIAMOND" ["pagetitle"]=> string(13) "BLACK DIAMOND" ["parent"]=> string(3) "127" ["privatemgr"]=> string(1) "0" ["privateweb"]=> string(1) "0" ["pub_date"]=> string(1) "0" ["published"]=> string(1) "1" ["publishedby"]=> string(1) "0" ["publishedon"]=> string(1) "0" ["richtext"]=> string(1) "1" ["searchable"]=> string(1) "1" ["template"]=> string(1) "8" ["type"]=> string(8) "document" ["unpub_date"]=> string(1) "0" }
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
and this is what i get if i use this code in the snippet:
<?php
$tv = $modx->getTemplateVarOutput('SKIN_HS_image', 124, 1);
echo $tv;
die(var_dump($tv));
?>
results in:
Arrayarray(1) { ["SKIN_HS_Image"]=> string(66) "http://www.domain.com:8383/assets/images/skin/hs_blackdiamond.jpg" }
so now the questions is - how to pull that image value from an array ?
Aleks
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
got it to work... here is the code i use:
<?php
$tv = $modx->getTemplateVarOutput("SKIN_HS_image", 124, 1);
if (is_array($tv))
{
foreach ($tv as $key=>$val)
{
$out = $val;
}
}
echo $out;
?>
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
$tv[’SKIN_HS_image’] should be what you want (getTemplateVarOutput returns an array of one or more tv values).
i still get an array:
Arrayarray(1) { ["SKIN_HS_Image"]=> string(66) "
http://www.domain.com:8383/assets/images/skin/hs_blackdiamond.jpg" }
MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5
I think that you actually want to echo $tv[’SKIN_HS_image’] .