The Joomla! Forum ™





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 111 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
PostPosted: Fri May 22, 2009 8:01 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Oct 01, 2007 11:35 am
Posts: 522
You could try looking at the javascript triggered by opening a tab, and then see if you can add to that trigger something that will hide the module using JPane. But I think it would be a lot of hassle.


Top
 Profile  
 
PostPosted: Fri May 22, 2009 12:54 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sat Jan 14, 2006 1:59 pm
Posts: 181
Location: Sunderland UK
With great thanks to coolparth
viewtopic.php?p=1703749#p1703749

Code:
<?php
               $my =& JFactory::getUser();
               //Followed by your code..
               if($my->id>0){
               echo "<jdoc:include type=\"modules\" name=\"right\" headerLevel=\"3\" />";
               }else
               {
               echo "<jdoc:include type=\"modules\" name=\"top\" headerLevel=\"3\" />";
               }
            ?>


I now have this working perfect,
Thanks :)

_________________
http://www.JoomlaSiteMonitor.com
Joomla Security and backup suite.
http://www.NewWorldDesigns.co.uk
Design - CMS - Ecommerce – SEO


Top
 Profile  
 
PostPosted: Wed Jul 08, 2009 12:38 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sat Nov 04, 2006 1:39 pm
Posts: 107
Location: Hyderabad, India
If any of you are still looking for this hack for 1.0.15, for a custom module (type USER), you would have to edit custom.xml. Took me a while to figure it out, and thought it might help someone.
Thanks for the hack.

_________________
http://www.winnou.com


Top
 Profile  
 
PostPosted: Tue Jul 28, 2009 8:44 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Nov 07, 2005 3:45 am
Posts: 579
anyone get this working for 1.5 AND the hack for only certain users? There's no frontend.php file in 1.5...


Top
 Profile  
 
PostPosted: Tue Jul 28, 2009 8:52 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10763
Location: Ireland
Hi,

You can use MetaMod to do that.

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Tue Jul 28, 2009 9:03 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Nov 07, 2005 3:45 am
Posts: 579
and that module will allow me to hide other modules or just that one module?


Top
 Profile  
 
PostPosted: Tue Jul 28, 2009 9:13 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10763
Location: Ireland
You can show different modules and hide any module which is loaded by that module.

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Fri Mar 19, 2010 12:20 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Wed Aug 01, 2007 12:08 am
Posts: 232
Location: Kent, UK
[quote="kevincam"][/quote]

Kevincam,thanks very much for the hack! Works' great!!! :D :D :D

_________________
Company site - http://www.stormit.co.uk
Follow me on Twitter - http://twitter.com/stormit


Top
 Profile  
 
PostPosted: Thu Mar 25, 2010 5:58 am 
Joomla! Intern
Joomla! Intern

Joined: Sat Mar 25, 2006 1:01 pm
Posts: 95
Hi,

Here is a solution for Joomla 1.5.

1. Download and install Jumi: http://extensions.joomla.org/extensions/1023/details
2. Edit the module you want to hide for regestrated users on your site. In the combo box labelled "Position". Intead of using the drop down list, type in a name of your liking. For example user100.
3. Now you create a new Jumi module.

Settings: no title and choose a position where you want to show your module.

Insert this code to inside "Code written" in the Jumi module.

Code:
<?php
$position = 'user100';
$user =& JFactory::getUser();
if($user->guest)
{
  $document   = &JFactory::getDocument();
  $renderer   = $document->loadRenderer('modules');
  $contents = '';
  echo $renderer->render($position, array('style'=>'xhtml'));
}
?>
 



Top
 Profile  
 
PostPosted: Fri Mar 26, 2010 8:17 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Dec 25, 2009 11:33 pm
Posts: 13
Location: USA, Texas
da8iwr wrote:
With great thanks to coolparth
viewtopic.php?p=1703749#p1703749

Code:
<?php
               $my =& JFactory::getUser();
               //Followed by your code..
               if($my->id>0){
               echo "<jdoc:include type=\"modules\" name=\"right\" headerLevel=\"3\" />";
               }else
               {
               echo "<jdoc:include type=\"modules\" name=\"top\" headerLevel=\"3\" />";
               }
            ?>


I now have this working perfect,
Thanks :)


Me a lika very much sir! Ita Saves my day!


Top
 Profile  
 
PostPosted: Mon May 03, 2010 5:13 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Nov 07, 2005 3:45 am
Posts: 579
no longer working since 1.5.16 - I tried to redo hack with no luck. Did I do something wrong or are we going to have to find another way to do this?


Top
 Profile  
 
PostPosted: Mon May 03, 2010 9:03 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Dec 25, 2009 11:33 pm
Posts: 13
Location: USA, Texas
Code:
<?php
               $my =& JFactory::getUser();
               //Followed by your code..
               if($my->id>0){
               echo "<jdoc:include type=\"modules\" name=\"right\" headerLevel=\"3\" />";
               }else
               {
               echo "<jdoc:include type=\"modules\" name=\"top\" headerLevel=\"3\" />";
               }
            ?>


You tried this code? This one worked flawless for me. However, am using 1.5.15 so if this one doesn't work then it would be good to know.


Top
 Profile  
 
PostPosted: Mon May 03, 2010 9:12 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Nov 07, 2005 3:45 am
Posts: 579
jgage wrote:
Code:
<?php
               $my =& JFactory::getUser();
               //Followed by your code..
               if($my->id>0){
               echo "<jdoc:include type=\"modules\" name=\"right\" headerLevel=\"3\" />";
               }else
               {
               echo "<jdoc:include type=\"modules\" name=\"top\" headerLevel=\"3\" />";
               }
            ?>


You tried this code? This one worked flawless for me. However, am using 1.5.15 so if this one doesn't work then it would be good to know.
where does that code go?


Top
 Profile  
 
PostPosted: Tue May 04, 2010 9:58 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10763
Location: Ireland
You can add that into your template's index.php file, moreover you can use the metamod module as well.

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Wed May 05, 2010 4:24 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Nov 07, 2005 3:45 am
Posts: 579
ok, it actually does still work - I just had to redo it and I messed up first time. This is from kevincam's post on page 3:

Added this after the last parameter of the XML file for whatever module you want to hide for example the login module which is located here (modules\mod_login\mod_login.xml):

Code:
<param name="show_registered" type="radio" default="1" label="Show Menu When Logged In" description="Show the menu also when a registered user is logged in">
<option value="0">No</option>
<option value="1">Yes</option>
</param>



Then replace the function render( $position, $params = array(), $content = null ) in \libraries\joomla\document\html\renderer\modules.php with the following


Code:
function render( $position, $params = array(), $content = null )
{
$renderer =& $this->_doc->loadRenderer('module');

$contents = '';
foreach (JModuleHelper::getModules($position) as $mod) {
// HACK: added code to check if module should be shown when a user is logged in
$pattern = '/show_registered=0/';
$match = preg_match($pattern, $mod->params);
$userId = $_SESSION["__default"]['user']->id;
if ($match && $userId) {
// simply continue the loop without outputting this module
continue;
}
// --- end HACK ---
$contents .= $renderer->render($mod, $params, $content);
}
return $contents;
}


UPDATED: I noticed that modules that use the module count need an additional hack to the file:
\libraries\joomla\application\module\helper.php

after the line $modules = array();
and before the line $db->setQuery( $query );

Code:
//HACK check in logged in then run query to exclude the correct modules
if($userId = $_SESSION["__default"]['user']->id >0){
$wheremenu = isset( $Itemid ) ? ' AND ( mm.menuid = '. (int) $Itemid .' OR mm.menuid = 0 )' : '';
$query = 'SELECT id, title, module, position, content, showtitle, control, params'
. ' FROM #__modules AS m'
. ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'
. ' WHERE m.published = 1'
. ' AND m.access <= '. (int)$aid
. ' AND m.client_id = '. (int)$mainframe->getClientId()
. " AND m.id NOT IN (SELECT id FROM #__modules WHERE params LIKE '%show_registered=0%')"
. $wheremenu
. ' ORDER BY position, ordering';
}else{
$wheremenu = isset( $Itemid ) ? ' AND ( mm.menuid = '. (int) $Itemid .' OR mm.menuid = 0 )' : '';
$query = 'SELECT id, title, module, position, content, showtitle, control, params'
. ' FROM #__modules AS m'
. ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'
. ' WHERE m.published = 1'
. ' AND m.access <= '. (int)$aid
. ' AND m.client_id = '. (int)$mainframe->getClientId()
. $wheremenu
. ' ORDER BY position, ordering';
}
//HACK

/*ORIGINAL CODE
$wheremenu = isset( $Itemid ) ? ' AND ( mm.menuid = '. (int) $Itemid .' OR mm.menuid = 0 )' : '';
$query = 'SELECT id, title, module, position, content, showtitle, control, params'
. ' FROM #__modules AS m'
. ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'
. ' WHERE m.published = 1'
. ' AND m.access <= '. (int)$aid
. ' AND m.client_id = '. (int)$mainframe->getClientId()
. $wheremenu
. ' ORDER BY position, ordering';
ORIGINAL CODE*/


Top
 Profile  
 
PostPosted: Fri Jun 04, 2010 11:13 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Jun 02, 2010 6:32 pm
Posts: 8
Okay, what's the best way to do this in Joomla 1.5.15?

I just want to hide one module. Not the entire position (e.g. top) just the one of multiple modules that appear in that position.

I used MetaMod.

Does anyone know how I can have a different css for logged in user than for non-logged in user?


Last edited by Josh_D on Fri Jun 04, 2010 11:39 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Jun 04, 2010 11:21 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Nov 07, 2005 3:45 am
Posts: 579
this method is still valid, but a lot of people are using metamod instead. this is the post that explains how to do it in 1.5: viewtopic.php?p=1323633#p1323633


Top
 Profile  
 
PostPosted: Fri Jun 04, 2010 11:40 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Jun 02, 2010 6:32 pm
Posts: 8
Cool, thanks.
I used MetaMod.

Does anyone know how I can have a different css for logged in user than for non-logged in user?
Can that also be done in metamod?


Top
 Profile  
 
PostPosted: Sat Aug 07, 2010 8:38 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jun 16, 2009 7:33 pm
Posts: 22
Location: UK
Ach, spent nearly 3 hours trying to get kevincam's hack to work (kept getting a parse error, unexpected "{" expecting T_FUNCTION on line 54 of the modules.php file) then I come across the post about MetaMod... D'oh! Live & leanr I guess coz it took a fraction of the time to get started with, however I added "if ( MM_LOGGED_IN ) return 17;" to the PHP box hoping it would show the User Menu (in place of the login form) but it doesn't show anything at all once I've logged in.

Also, the mod'd form doesn't show the Open ID links, I tried adding its ID after the login form's one (yeah I'm aware that it's a plugin and not a module, but as of yet I've not been able to find any Open ID modules so I figured it was at least worth a punt :p ) but it didn't work.

Anyone got an idea how to resolve these? ??? ??? ???

(fyi for anyone who decides to try it out themselves on my site, I've left the original login form next to the MetaMod'd one to make it easy for myself to compare differences in them :D )

_________________
It's not a signature, it's a dictatorship! :-(


Top
 Profile  
 
PostPosted: Fri Jan 14, 2011 3:03 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Wed Mar 24, 2010 6:59 am
Posts: 2
Hi,

This is my solution for Joomla 1.5.xx

The hack will allow specific module to be displayed for a specific type of user(/s).

1. Replace render function with code below @ \libraries\joomla\document\html\renderer\modules.php
Code:
    function render($position, $params = array(), $content = null) {
        $renderer = & $this->_doc->loadRenderer('module');

        $contents = '';
        foreach (JModuleHelper::getModules($position) as $mod) {
            // BEGIN HACK
            // added function to check if module is allowed to be displayed for a specific user typ
            $gId = JFactory::getUser()->gid;
            for ($i = 0; $i < 26; $i++) {
                if ($i == $gId) {
                    $pattern = '/show_' . $i . '=0/';
                    $hidemodule = preg_match($pattern, $mod->params);
                }
            }
            if ($hidemodule) {
                // simply continue the loop without outputting this module
                continue;
            }
            // END HACK
            $contents .= $renderer->render($mod, $params, $content);
        }
        return $contents;
    }


2. Add the paramaters below to your mod_{module}.xml file
Code:
<param type="spacer" default="&lt;b&gt;Display Module For...&lt;/b&gt;" />
<param name="show_0" type="radio" default="1" label="Public Users" description="Toggle Module Display for specific User Type">
   <option value="0">No</option>
   <option value="1">Yes</option>
</param>
<param name="show_18" type="radio" default="18" label="Registered Users" description="Toggle Module Display for specific User Type">
   <option value="0">No</option>
   <option value="18">Yes</option>
</param>
<param name="show_19" type="radio" default="1" label="Author Users" description="Toggle Module Display for specific User Type">
   <option value="0">No</option>
   <option value="1">Yes</option>
</param>
<param name="show_20" type="radio" default="1" label="Editor Users" description="Toggle Module Display for specific User Type">
   <option value="0">No</option>
   <option value="1">Yes</option>
</param>
<param name="show_21" type="radio" default="1" label="Publisher Users" description="Toggle Module Display for specific User Type">
   <option value="0">No</option>
   <option value="1">Yes</option>
</param>
<param name="show_23" type="radio" default="1" label="Manager Users" description="Toggle Module Display for specific User Type">
   <option value="0">No</option>
   <option value="1">Yes</option>
</param>
<param name="show_24" type="radio" default="1" label="Administrator Users" description="Toggle Module Display for specific User Type">
   <option value="0">No</option>
   <option value="1">Yes</option>
</param>
<param name="show_25" type="radio" default="1" label="Super Administrator Users" description="Toggle Module Display for specific User Type">
   <option value="0">No</option>
   <option value="1">Yes</option>
</param>


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
PostPosted: Tue Apr 05, 2011 12:06 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Nov 07, 2005 3:45 am
Posts: 579
yajra, that hack does make the module invisible, but it does not remove the module form the structure. In other words, the space for the module is still there. For example, mine is set to show on my front page. When I log in the module is gone, but the left column is empty.

So your hack is not really working as it should. I recommend going back to the hack on page 3.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 111 posts ]  Go to page Previous  1, 2, 3, 4



Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group