2013-03-28 32 views
1

我在Opencart的網站3個客戶羣體如下:Opencart的:隱藏自定義菜單時指定組cusomer登錄

  • 所有者 - ID 1
  • 賣家 - ID 2
  • 嘉賓 - ID 3

用戶只有登錄後才能訪問我的opencart網站 - 工作正常。我在我的網站的標題中添加了一個自定義菜單項,例如

<a href="<?php echo $cusomtlink; ?>">Custome Menu</a> 

我quetion是:如何隱藏客戶組ID 2這個自定義菜單項?

+0

@shadyyx我沒有嘗試過任何東西..因爲我不知道我開始...你能提出任何想法嗎? – mans 2013-03-28 12:08:14

回答

1

去你catalog/controller/common/header.php頭控制器和$this->render();行之前添加此行:

$this->data['customer_group_id'] = $this->customer->getCustomerGroupId(); 

然後去你的頭模板文件,其中添加自定義菜單項,並將其改成這樣:

<?php if($customer_group_id != 2) { ?> 
<a href="<?php echo $cusomtlink; ?>">Custom Menu</a> 
<?php } ?> 

這應該做到這一點。

編輯:如果你需要隱藏多個組菜單項,你可以這樣做:

<?php if(!in_array($customer_group_id, array(2, 3, 7, 8))) { ?> 
<a href="<?php echo $cusomtlink; ?>">Custom Menu</a> 
<?php } ?> 
+0

@shaddyx你的回答是正確的,謝謝......但有一個問題,如何隱藏這個菜單甚至是組ID 3客戶也登錄過。 – mans 2013-03-30 07:38:11

+0

@mans查看我編輯的答案。 – shadyyx 2013-03-30 11:23:03

+0

@shaddyx ...你是對的......它的工作正常......感謝你的偉大答案.. – mans 2013-03-30 11:24:39