2012-10-19 42 views
0

Joomla 2.5 有沒有辦法將特定的css類添加到特定於已登錄用戶組的主體中。Joomla:根據用戶組添加一個頁面類

例如,我有四個用戶組,分別是Premium,Individual Standard,Corporate Premium和Corporate Standard。我想有這樣的:

<body class="individual-standard"> 

<body class="corporate-standard"> 

這是當前的身體標記:

<body id="ff-<?php echo $fontfamily; ?>" class="<?php echo $fontstyle; ?> <?php echo $pstyle; ?> <?php echo $bgstyle; ?> <?php echo $pageclass; ?> iehandle"> 

我試圖把這個在頭上:

$user =& JFactory::getUser(); 
    $pageclass =""; 
    if(array_key_exists('individual premium',$user->groups)){ 
    $pageclass .="individual-premium"; 
    } 
    if(array_key_exists('corporate premium',$user->groups)){ 
    $pageclass .="corporate-premium"; 
    } 
    if(array_key_exists('corporate standard',$user->groups)){ 
    $pageclass .="corporate-standard"; 
    } 
    if(array_key_exists('individual standard',$user->groups)){ 
    $pageclass .="individual-standard"; 
    } 

這是主體標籤:

<body id="ff-<?php echo $fontfamily; ?>" class="<?php echo $fontstyle; ?> <?php echo $pstyle; ?> <?php echo $bgstyle; ?> <?php echo $pageclass; ?> iehandle"> 

回答

1

首先獲得用戶組和比設置類按代碼 -

低於在模板文件夾

$user =& JFactory::getUser(); 
    $pageclass =""; 
    if(array_key_exists('individual premium',$user->groups)){ 
    $pageclass .="individual-premium"; 
    } 
    if(array_key_exists('corporate premium',$user->groups)){ 
    $pageclass .=" corporate-premium"; 
    } 
    if(array_key_exists('corporate standard',$user->groups)){ 
    $pageclass .=" corporate-standard"; 
    } 
    if(array_key_exists('individual standard',$user->groups)){ 
    $pageclass .=" individual-standard"; 
    } 

     <body id="ff-<?php echo $fontfamily; ?>" class="<?php echo $fontstyle; ?> <?php echo $pstyle; ?> <?php echo $bgstyle; ?> <?php echo $pageclass; ?> iehandle"> 

的index.php文件,例如,如果在「企業高級用戶「和」企業標準「組 頁面類將爲-corporate-premium corporate-standard