Jump to content

[Solved] Whats the Smarty variable for User id and group id ?


danmikkelsen

Recommended Posts

Hi,

it's depends on which page you are maybe, here some you can have everywhere (or almost)

$cookie->id_customer maybe.

For the group, you can use $customer->getGroups() or Customer::getGroupsStatic($id_customer); but you can find better, sorry I don't remember exactly.

  • Thanks 1
Link to comment
Share on other sites

  • 5 months later...
  • 2 months later...

I used this on the override FrontController.php (attached). You should copy the entire FrontController.php and paste it on /override/classes/FrontController.php. Paste the following code on line 32.

 

This checks if a user is on certain group.

 

$customer = new Customer(intval($cookie->id_customer));
/* The group (number 1, in this case) you want to check */
$specificGroup = $customer->isMemberOfGroup(1);
$smarty->assign('customerGroup', $specificGroup);

 

I created the "customerGroup" variable and I used it on the blockcategories.tpl file to show another categories block with only certain categories (the ones who's have a special discount). As you can see, I wanted to show categories 22, 23 and 24.

 

 

{if $customerGroup}	  
<div id="categories_block_left" class="block">
<h4>{l s='Categories' mod='blockcategories'}</h4>
<div class="block_content">
 <ul class="tree {if $isDhtml}dhtml{/if}">
 {foreach from=$blockCategTree.children item=child name=blockCategTree}
{* If the category is 22, 23 or 24, show it *}
  {if $child.id==22 || $child.id==23 || $child.id==24}
{if $smarty.foreach.blockCategTree.last}
 {include file="$branche_tpl_path" node=$child last='true'}
{else}
 {include file="$branche_tpl_path" node=$child}
{/if}
  {/if}
 {/foreach}
 </ul>
 {* Javascript moved here to fix bug #PSCFI-151 *}
 <script type="text/javascript">
 // <![CDATA[
  // we hide the tree only if JavaScript is activated
  $('div#categories_block_left ul.dhtml').hide();
 // ]]>
 </script>
</div>
</div>
{/if}

 

Good luck.

 

Note: It worked perfectly with 1.4.5.1, but with 1.4.6.2 it throws a warning and I get it working just by adding the code directly to the FrontController.php file (and not the override one). Anyway, this is the wrong way ;)

FrontController.php

  • Like 2
Link to comment
Share on other sites

  • 1 year later...

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