Jump to content

function on .tpl


uzziell

Recommended Posts

i want to ask about this code : 

 

$id_image = Product::getCover('2');
if (sizeof($id_image) > 0) {
$image = new Image($id_image['id_image']);
$image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg";
}
 
How to put this code on .tpl 
and i want to echo $image_url
 
please help me thank
Link to comment
Share on other sites

it's not possible to put php code to the .tpl files

in this case create static function in frontController


public static function MyFunction($id){
$id_image = Product::getCover($id);
if (sizeof($id_image) > 0) {
$image = new Image($id_image['id_image']);
$image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg";
return $image_url;
}

 

then you can call this in your .tpl files:
 
{FrontController:MyFunction(2)}
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...