rezeptionist
Aktives Mitglied
Hallo miteinander,
Ich habe ein kleines Problerm in der Artikel.tpl,
ich will den Artikelpreis in der Artikel.tpl als variable haben um sie in einem php tag in Grafiken umzuwandeln.
Ist das möglich
Hier mal etwas code:
wie bekomme ich nun den Preis in die variable $price ??
Vielen Dank im voraus
Rezeptionist
Ich habe ein kleines Problerm in der Artikel.tpl,
ich will den Artikelpreis in der Artikel.tpl als variable haben um sie in einem php tag in Grafiken umzuwandeln.
Ist das möglich
Hier mal etwas code:
Code:
{php}
function getPriceAsImage($price)
{
// Zahlen als Grafiken, bei Bedarf anpassen
$images = array('gfx/0.gif','[img]/gfx/1.png[/img]','gfx/2.gif','gfx/3.gif','gfx/4.gif','gfx/5.gif','gfx/6.gif','gfx/7.gif','gfx/8.gif','[img]/gfx/9.png[/img]');
$image_comma = '[img]/gfx/komma.png[/img]';
$number = array(0,1,2,3,4,5,6,7,8,9);
if(is_numeric($price)){ $dot = explode(".", $price);
if(!empty($dot[1])) {
$price_string = str_replace($number, $images, $dot[0]);
$price_string .= $image_comma;
$price_string .= str_replace($number, $images, $dot[1]);
}else{
$price_string = str_replace($number, $images, $price);
}
}
return $price_string;
}
// Funktion-Aufruf
$price = 19.99;
$new_price = '[img]/gfx/euro.png[/img]';
$new_price .= getPriceAsImage($price);
echo $new_price;
{/php}
wie bekomme ich nun den Preis in die variable $price ??
Vielen Dank im voraus
Rezeptionist