Jump to content

Assign smarty variable from public function in frontcontroller.php


Recommended Posts

Hello all,

 

I used a public function like discussed in this topic : https://www.prestashop.com/forums/topic/327206-solved-creating-category-links/. I have called the function in a .tpl using instruction : {assign var="varFront" value=FrontController::getCategoryName($varCat.id_category)}

public static function getCategoryName($id){

		$category = new Category ($id,Context::getContext()->language->id);
		
		$variableTest = $category->name;
		return $variableTest;

	}

I am able to call this function and get back the category-name  based upon the param 'id'.

Is it possible to also pass the object 'category' to the .tpl instead of only the propertie 'name', using smarty for example?

 

I started trying to pass the name using smarty assing but its not working:

public static function getCategoryName($id){

		$category = new Category ($id,Context::getContext()->language->id);
		$this->context->smarty->assign('varTestSmarty', $category->name);
		$variableTest = $category->name;
		return $variableTest;

	}

Is it possible to pass the object using smarty assign? Or is it possible to return the object ( in that case , how do i catch the object in the .tpl ?)

 

Thanks in advance for your input !

 

Rob

 

 

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...