简体   繁体   中英

Show specific logo for user group in Joomla 3

I can't seem to see a logical way to do this, I've tried many different functions, some of which i get blank page errors, other which it seems to work but just skips and goes to the else function everytime.

In a nutshell, I'm trying to have it so that certain logos will be displayed depending on the User Group ID.

At the moment the code below is producing a blank error page, and I can't see why.

Could anyone help me with this? Joomla 3.1 by the way.

<?php $user = JFactory::getUser();
    $usergroup=$user->getAuthorisedGroups();
    if ($usergroup == '10') : ?>
        <a href="<?php echo JURI::root(); ?>" id="gkLogo">
            <img src="/images/fordlogo.png" alt="<?php echo $this->API->getPageName(); ?>" />
        </a>
    <?php elseif ($usergroup == '7') : ?>
        <a href="<?php echo JURI::root(); ?>" id="gkLogo">
            <img src="/images/tescologo.png" alt="<?php echo $this->API->getPageName(); ?>" />
        </a>
    <?php else; ?>
        <a href="<?php echo JURI::root(); ?>" id="gkLogo">
            <img src="<?php echo $logo_image; ?>" alt="<?php echo $this->API->getPageName(); ?>" />
        </a>
    <?php endif; ?>

Try something like this,

$user = JFactory::getUser();
$usergroup = $user->getAuthorisedGroups();

if(in_array('10',$usergroup)){
    echo '<a href="'.JURI::root().'" id="gkLogo">
            <img src="/images/fordlogo.png" alt="'.$this->API->getPageName().'" />
          </a>';
}elseif(in_array('7',$usergroup)){
    echo '<a href="'.JURI::root().'" id="gkLogo">
            <img src="/images/fordlogo.png" alt="'.$this->API->getPageName().'" />
          </a>';    
}else{
    echo '<a href="'.JURI::root().'" id="gkLogo">
            <img src="/images/fordlogo.png" alt="'.$this->API->getPageName().'" />
          </a>';    
}

Hope this will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM