[!Ditto? &parents=`21,23,26` &total=`3` &tpl=`tcTplShopItem` &tplLast=`tcTplShopItemLast` &extenders=`tcPriceGetter`!]
<?php
if (!function_exists("tcPriceGetter")) {
function tcPriceGetter($resource) {
$productID = $resource["tcProductID"];
$query = "SELECT amount FROM modx_treasure_chest WHERE id=$productID";
$tcPrice = $modx->db->query($query);
return $tcPrice;
}
}
$placeholders['tcPrice'] = array("tcPriceGetter","tcProductID");
?>Error: call_user_func(tcProductID) [function.call-user-func]: First argument is expected to be a valid callback Line 259 source: $placeholders[$name] = call_user_func($value[1],$resource);
$placeholders['tcPrice'] = array(array("tcProductID","*"),"tcPriceGetter");
[!Ditto? &parents=`21,23,26` &total=`3` &tpl=`tcTplShopItem` &tplLast=`tcTplShopItemLast` &extenders=`tcPriceGetter`!]
<li> <a class="imgPreviewLink" href="[~[+id+]~]" title="[+longtitle+]"> <img src="/assets/snippets/treasure_chest/images/phpthumb/phpThumb.php?src=../products/[+alias+].jpg&w=125&f=png" alt="[+pagetitle+]"> </a> <h3> <a href="[~[+id+]~]" title="[+longtitle+]">[+pagetitle+]</a> </h3> <p class="productAdd"><a href="#" onclick="return false;" class="addToCart" title="Add this piece to your cart" name="[+tcProductID+]" rel="id"><span>Add To Cart</span></a></p> <p>[+tcPrice+]</p> </li>
<?php
if (!function_exists("tcPriceGetter")) {
function tcPriceGetter($resource) {
$productID = $resource["tcProductID"];
$query = "SELECT amount FROM modx_treasure_chest WHERE id=$productID";
$tcPrice = $modx->db->query($query);
return $tcPrice;
}
}
$placeholders['tcPrice'] = array(array("tcProductID","*"),"tcPriceGetter");
?>[error] PHP Fatal error: Call to a member function query() on a non-object in /path/assets/snippets/ditto/extenders/tcPriceGetter.extender.inc.php on line 9
<?php
if (!function_exists("tcPriceGetter")) {
function tcPriceGetter($resource) {
global $modx;
$productID = $resource["tcProductID"];
$table = $modx->getFullTableName('treasure_chest');
$query = "SELECT amount FROM $table WHERE id=$productID";
$result = $modx->db->query($query);
$tcPrice = $modx->db->getValue($result);
return ($tcPrice < 1) ? 'No price found' : $tcPrice;
}
}
$placeholders['tcPrice'] = array(array("tcProductID","*"),"tcPriceGetter");
?>