Jump to content

Request: List of all variables to use in Smarty templates


Recommended Posts

You may look at smarty.net... You can also activate the debug window...

 

Have fun.

What do you mean by debug window? The one inside my browser?

 

It varies. Really, any variables can be used in smarty. What are you trying to do, we may be able to help.

Well I was looking at some templates inside PrestaShop..

What I was trying to do is hide the Shipping and Total costs, and the Check-out button in the Cart Block if the Cart is empty. I managed to do this successfully using the {if $products} tag.

And I was wondering if there is a list available of all variables and tags..

Ill just have a look at smarty.net!

 

Thanks for replying!

Link to comment
Share on other sites

What do you mean by debug window? The one inside my browser?

 

Go to the config/config.inc.php file and set $smarty->debugging to true ;)

Thanks for pointing in the right direction.

 

Another thing I'm trying to accomplish is to adjust the Userinfo Block to show:

Welcome mr./ms. (depending on gender) $Costumername.

 

I've had a look in the identity template to find the correct variables but I just can't get it to work.

This is the line of code I've added:

 

{if $id_gender eq '1'}mr. {else}mrs. {/if}<span>{$customerName}</span>

 

 

Since that I'm a noob when it comes to Smarty the code above is incorrect and just shows mrs.

 

Can you show me what do I have to put in place of {if $id_gender eq '1'}?

Link to comment
Share on other sites

Well, the blockuserinfo block does not return the needed information.

You have to modify it...

 

Go to /modules/blockuserinfo/blockuserinfo.php and replace

 

	function hookTop($params)
{
	global $smarty, $cookie, $cart;

	$smarty->assign(array(
		'cart' => $cart,
		'cart_qties' => $cart->nbProducts(),
		'logged' => $cookie->isLogged(),
		'customerName' => ($cookie->logged ? $cookie->customer_firstname.' '.$cookie->customer_lastname : false)
	));
	return $this->display(__FILE__, 'blockuserinfo.tpl');
}

 

with

 

	function hookTop($params)
{
	global $smarty, $cookie, $cart;

	$customer = new Customer(intval($cookie->id_customer));

	$smarty->assign(array(
		'cart' => $cart,
		'cart_qties' => $cart->nbProducts(),
		'logged' => $cookie->isLogged(),
		'customerName' => ($cookie->logged ? $cookie->customer_firstname.' '.$cookie->customer_lastname : false),
		'id_gender' => $customer -> id_gender
	));
	return $this->display(__FILE__, 'blockuserinfo.tpl');
}

Link to comment
Share on other sites

The first one gets the customer "properties" (you may add print_r($customer); in blockuserinfo.php to see all the customers variables).

 

The second one assigns the attribute we need (id_gender) to a smarty variable.

 

Have fun :)

Link to comment
Share on other sites

The first one gets the customer "properties" (you may add print_r($customer); in blockuserinfo.php to see all the customers variables).

 

The second one assigns the attribute we need (id_gender) to a smarty variable.

 

Have fun :)

Thanks alot you really helped me out on this one! :)

 

 

Another thing is, I want to turn caption on the costumers lastname off..

Link to comment
Share on other sites

I am sure you can find the solution yourself in the /modules/blockuserinfo/blockuserinfo.php file :)

I can't find anything inside the code that sets the uppercase.. I also added text-transform: capitalize  style to the blockuserinfo.tpl file but that doesnt do the trick. However, if i replace capitalize with lowercase, it does transform the lastname in lowercase characters.
Link to comment
Share on other sites

  • 4 years later...
×
×
  • Create New...