Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • austenn01 Friend
    #687152

    Hello,

    In the Category Item layout, there is the ‘cog icon’ at top right corner of each Article, and once clicked it shows a drop menu with: print, email, and edit )shows edit if user have permissions to edit).

    What I want to do is only show the Cog Icon to Super Administrators for example.

    So to do this, I need to know what php code to use in the template/html/com_content/category/xxx_item.php file.

    I need to wrap the blow code in some php code that says (only show the below code if user in in the Supper Administrator Joomla User group (group id=8).

    <!-- Aside -->
    <?php if ($topInfo || $icons) : ?>
    <aside class="article-aside clearfix">

    <dl class="article-info">
    <dt class="article-info-term">
    <?php echo JText::_('COM_CONTENT_ARTICLE_INFO'); ?>
    </dt>
    <?php if ($params->get('show_author') && !empty($this->item->author)) : ?>
    <?php echo JLayoutHelper::render('joomla.content.info_block.author', array('item' => $this->item, 'params' => $params)); ?>
    <?php endif; ?>

    Thanks,

    EDIT:

    Oh..I need to add one more rule. I need to be able to hide the Cog Icon by defining multiple Joomla User Groups (IE: Super Admin, Administrator, Manager) OR to show the Cog Icon to all Joomla User Groups above ‘Manager’ for example.

    austenn01 Friend
    #687214

    Ok, I found this code:

    <?php
    $user =& JFactory::getUser();
    $uid = $user->id;

    jimport( 'joomla.access.access' );
    $groups = JAccess::getGroupsByUser($uid, false);
    if(in_array(8, $groups)){
    echo 'only visible for super-admin test';
    }

    ?>

    If i add this to my template/html/com_content/category/xxx_item.php file, I will only see this text: “only visible for super-admin test” when i am logged in as a super administrator.

    The issue I have (as I dont know how to write php), is how to use the code just above and add the code from my original post to it.

    Can someone please help?

    austenn01 Friend
    #749093

    Ok, I found this code:

    <?php
    $user =& JFactory::getUser();
    $uid = $user->id;

    jimport( 'joomla.access.access' );
    $groups = JAccess::getGroupsByUser($uid, false);
    if(in_array(8, $groups)){
    echo 'only visible for super-admin test';
    }

    ?>

    If i add this to my template/html/com_content/category/xxx_item.php file, I will only see this text: “only visible for super-admin test” when i am logged in as a super administrator.

    The issue I have (as I dont know how to write php), is how to use the code just above and add the code from my original post to it.

    Can someone please help?

    Ninja Lead Moderator
    #687257

    Hi,

    In this case, you can try to do with my solution below

    Open templates/ja_medicare/html/layouts/joomla/content/icons.php file and add code above as my screenshot


    <?php
    /**
    * @package Joomla.Site
    * @subpackage Layout
    *
    * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
    * @license GNU General Public License version 2 or later; see LICENSE.txt
    */

    defined('JPATH_BASE') or die;

    $canEdit = $displayData['params']->get('access-edit');

    $user = JFactory::getUser();
    $uid = $user->id;

    jimport( 'joomla.access.access' );
    $groups = JAccess::getGroupsByUser($uid, false);

    ?>

    <div class="icons">
    <?php if(in_array(8, $groups)): ?>
    <?php if (empty($displayData['print'])) : ?>

    <?php if ($canEdit || $displayData['params']->get('show_print_icon') || $displayData['params']->get('show_email_icon')) : ?>
    <div class="btn-group pull-right">
    <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> <span class="icon-cog"></span> <span class="caret"></span> </a>
    <?php // Note the actions class is deprecated. Use dropdown-menu instead. ?>
    <ul class="dropdown-menu">
    <?php if ($displayData['params']->get('show_print_icon')) : ?>
    <li class="print-icon"> <?php echo JHtml::_('icon.print_popup', $displayData['item'], $displayData['params']); ?> </li>
    <?php endif; ?>
    <?php if ($displayData['params']->get('show_email_icon')) : ?>
    <li class="email-icon"> <?php echo JHtml::_('icon.email', $displayData['item'], $displayData['params']); ?> </li>
    <?php endif; ?>
    <?php if ($canEdit) : ?>
    <li class="edit-icon"> <?php echo JHtml::_('icon.edit', $displayData['item'], $displayData['params']); ?> </li>
    <?php endif; ?>
    </ul>
    </div>
    <?php endif; ?>

    <?php else : ?>

    <div class="pull-right">
    <?php echo JHtml::_('icon.print_screen', $displayData['item'], $displayData['params']); ?>
    </div>

    <?php endif; ?>
    <?php endif; ?>
    </div>

    Hope it helps

    Regards

    Ninja Lead Moderator
    #749136

    Hi,

    In this case, you can try to do with my solution below

    Open templates/ja_medicare/html/layouts/joomla/content/icons.php file and add code above as my screenshot


    <?php
    /**
    * @package Joomla.Site
    * @subpackage Layout
    *
    * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
    * @license GNU General Public License version 2 or later; see LICENSE.txt
    */

    defined('JPATH_BASE') or die;

    $canEdit = $displayData['params']->get('access-edit');

    $user = JFactory::getUser();
    $uid = $user->id;

    jimport( 'joomla.access.access' );
    $groups = JAccess::getGroupsByUser($uid, false);

    ?>

    <div class="icons">
    <?php if(in_array(8, $groups)): ?>
    <?php if (empty($displayData['print'])) : ?>

    <?php if ($canEdit || $displayData['params']->get('show_print_icon') || $displayData['params']->get('show_email_icon')) : ?>
    <div class="btn-group pull-right">
    <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> <span class="icon-cog"></span> <span class="caret"></span> </a>
    <?php // Note the actions class is deprecated. Use dropdown-menu instead. ?>
    <ul class="dropdown-menu">
    <?php if ($displayData['params']->get('show_print_icon')) : ?>
    <li class="print-icon"> <?php echo JHtml::_('icon.print_popup', $displayData['item'], $displayData['params']); ?> </li>
    <?php endif; ?>
    <?php if ($displayData['params']->get('show_email_icon')) : ?>
    <li class="email-icon"> <?php echo JHtml::_('icon.email', $displayData['item'], $displayData['params']); ?> </li>
    <?php endif; ?>
    <?php if ($canEdit) : ?>
    <li class="edit-icon"> <?php echo JHtml::_('icon.edit', $displayData['item'], $displayData['params']); ?> </li>
    <?php endif; ?>
    </ul>
    </div>
    <?php endif; ?>

    <?php else : ?>

    <div class="pull-right">
    <?php echo JHtml::_('icon.print_screen', $displayData['item'], $displayData['params']); ?>
    </div>

    <?php endif; ?>
    <?php endif; ?>
    </div>

    Hope it helps

    Regards

    austenn01 Friend
    #692011

    Hello Ninja Lead,

    Thanks for your reply…it does work, but I think you have completly missed the purpose of what I was asking and a few other things.

    Your option is incredibly limiting, as it hides the COG ICON for ALL pages, category’s etc. Which is NOT what I want.

    As per my request above, I want to hide the COG ICON in the category_item.php file, and ONLY this view. Honestly its a bit ridiculous to be showing the COG ICON with Print and Email on a category item listing page when we show snippets of maybe 9 or more joomla articles….why do we need to show 9 COG ICONS with 9 email and print options, its crazy and it looks ugly as hell. The only time this is a good option, is when someone with editing rights is logged on…as this makes frontend editing easier. But for the normal website visitor, its really silly to be showing the COG ICON on a category item page for each joomla article snippet.

    Can you assist with what I am trying to do?

    austenn01 Friend
    #749524

    Hello Ninja Lead,

    Thanks for your reply…it does work, but I think you have completly missed the purpose of what I was asking and a few other things.

    Your option is incredibly limiting, as it hides the COG ICON for ALL pages, category’s etc. Which is NOT what I want.

    As per my request above, I want to hide the COG ICON in the category_item.php file, and ONLY this view. Honestly its a bit ridiculous to be showing the COG ICON with Print and Email on a category item listing page when we show snippets of maybe 9 or more joomla articles….why do we need to show 9 COG ICONS with 9 email and print options, its crazy and it looks ugly as hell. The only time this is a good option, is when someone with editing rights is logged on…as this makes frontend editing easier. But for the normal website visitor, its really silly to be showing the COG ICON on a category item page for each joomla article snippet.

    Can you assist with what I am trying to do?

    Ninja Lead Moderator
    #692024

    Hi,

    I tried to find on template/html/com_content/category/ folder but I could not see category_item.php as you mentioned above, if you want to apply with only Category list you have to change from blog_item.php file

    + Copy plugins/system/t3/base-bs3/html/com_content/category/blog_item.php file

    + Paste template/html/com_content/category/ folder

    + Open blog_item.php file

    find and change

    <?php if ($icons): ?>
    <?php echo JLayoutHelper::render('joomla.content.icons', array('item' => $this->item, 'params' => $params)); ?>
    <?php endif; ?>

    to

    <?php if ($icons): ?>
    <?php
    $user = JFactory::getUser();
    $uid = $user->id;

    jimport( 'joomla.access.access' );
    $groups = JAccess::getGroupsByUser($uid, false);
    if(in_array(8, $groups)){
    echo JLayoutHelper::render('joomla.content.icons', array('item' => $this->item, 'params' => $params));
    }
    ?>
    <?php endif; ?>

    Hope it helps

    Regards

    Ninja Lead Moderator
    #749537

    Hi,

    I tried to find on template/html/com_content/category/ folder but I could not see category_item.php as you mentioned above, if you want to apply with only Category list you have to change from blog_item.php file

    + Copy plugins/system/t3/base-bs3/html/com_content/category/blog_item.php file

    + Paste template/html/com_content/category/ folder

    + Open blog_item.php file

    find and change

    <?php if ($icons): ?>
    <?php echo JLayoutHelper::render('joomla.content.icons', array('item' => $this->item, 'params' => $params)); ?>
    <?php endif; ?>

    to

    <?php if ($icons): ?>
    <?php
    $user = JFactory::getUser();
    $uid = $user->id;

    jimport( 'joomla.access.access' );
    $groups = JAccess::getGroupsByUser($uid, false);
    if(in_array(8, $groups)){
    echo JLayoutHelper::render('joomla.content.icons', array('item' => $this->item, 'params' => $params));
    }
    ?>
    <?php endif; ?>

    Hope it helps

    Regards

    austenn01 Friend
    #692369

    Hello,

    Thanks works…thankyou… category_item.php was in another JoomArt template I was working on (i want this feature for all the sites I develop).

    So the second thing I was after is how to reference more than 1 user group as per above, not just user group with id of 8. So how do I add more than 1 user group id, what code do i use?

    Thanks again,

    austenn01 Friend
    #749628

    Hello,

    Thanks works…thankyou… category_item.php was in another JoomArt template I was working on (i want this feature for all the sites I develop).

    So the second thing I was after is how to reference more than 1 user group as per above, not just user group with id of 8. So how do I add more than 1 user group id, what code do i use?

    Thanks again,

    Ninja Lead Moderator
    #692395

    Hi,

    I can’t replicate the second question, it’s general question for Joomla so pls try to raise the same question into Joomla forum for help.

    Regards

    Ninja Lead Moderator
    #749654

    Hi,

    I can’t replicate the second question, it’s general question for Joomla so pls try to raise the same question into Joomla forum for help.

    Regards

    austenn01 Friend
    #851871

    Hello,

    The code given above no longer works. When I click to EDIT from the COG drop menu, it takes me to a 403 error page saying: You are not permitted to use that link to directly access that page (#228).

    Can anyone help to fix this issue and also if anyone can help with my 2nd question from above?

    Thanks,

    Ninja Lead Moderator
    #855109

    Hi
    In this To check the problem on your site I need the URL of your site, admin login backend of your site and FTP account via Set as private reply. I will help you to detect this Issue directly on your site.

Viewing 15 posts - 1 through 15 (of 15 total)

This topic contains 14 replies, has 2 voices, and was last updated by  Ninja Lead 8 years, 10 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum