问题描述
Joomla 2.5有没有一种方法可以向正文中添加特定的CSS类,该类特定于已登录用户的组.
Joomla 2.5Is there a way to add a specific css class to the body which is specific to a logged in user's group.
例如,我有四个用户组,个人高级会员",个人标准",企业高级会员"和企业标准".我想要类似的东西:
For example I have four user groups, Individual Premium, Individual Standard, Corporate Premium and Corporate Standard. I want to have something like:
<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">
推荐答案
首先获取用户组,然后根据以下代码设置类-
You first get the user groups and than set the class as per below code-
在模板文件夹的index.php中
In index.php of template folder
$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">
例如,如果公司溢价"和公司标准"组中的用户页面类将是-corporate-premium corporate-standard
for example if a user in "corporate premium" and "corporate standard" grouppage class will be- corporate-premium corporate-standard
这篇关于Joomla:根据用户组添加页面类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!