Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Hide module position for logged

Hide module position for logged

Hi, it's probably very easy but cannot figure how.

I have two position sidebar-a and sidebar-c

I want the non-logged see only the sidebar-a this is simple but when logged i want to show only sidebar-c not sidebar-a

Again i'm sure it is very easy but for the moment i can display the sidebar-a for non-logged but the problem is when i log i always see the sidebar-a + the sidebar-c???

Thanks for any tips :)

neomale

neomale
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: Hide module position for logged

Hi neomale,

I think what you're saying is:

- it's easy to ensure that sidebar "c" only shows for logged in users (and not for guests), by just setting each module within it to be enabled for registered users only.
- it's impossible in normal Joomla to stop the modules in sidebar "a" from appearing once someone logs in.

There are a couple of ways to do this:

(1) Edit the template itself to include some code around the place where module position "a" is declared. You'd be looking for a line something like this:

<jdoc:include type="modules" name="sidebar-a" style="xhtml" />

If you can't find a line like this, then you're probably using one of the modern templates that uses a template framework, and these often do things differently. In that case, this approach won't work.

So, before that line, put the following:

<?php
$u = JFactory::getUser();
if ($u->id > 0) {
?>

and after the jdoc line:

<?php } ?>


Now, there are often complications with this approach based on how your template collapses the module position when there are no modules in it. That is, there's likely more code in the template that deals with that module position, and you would need to identify that code and modify it.


(2) This approach, using MetaMod Pro, should work on any type of template.

a - put all of the modules currently in sidebar-a into a new module position named sidebar-a-metamod. Just type that in the module position dropdown for each module. The dropdown accepts arbitrary text as well as the dropdown.

b - create a MetaMod module and place it into sidebar-a

c - in the MetaMod, set the "Show quick modules to:" dropdown to "non-logged-in users only"

d - in the MetaMod, type "sidebar-a-metamod" into the "Quick module id or position include" box

e - save the MetaMod.


Using this technique, the sidebar-a-metamod position becomes a sort of surrogate for the real sidebar-a position. When Joomla renders the sidebar-a position, it runs the MetaMod. The MetaMod checks to see if the user is logged in. If not (i.e. guest), then the MetaMod pulls in all the modules from the sidebar-a-metamod position and displays them inside sidebar-a.


Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1689
Total Polls:
6
Total Posts:
5941
Posts this week:
1
User Info:
 
Total Users:
5355
Newest User:
titus87954
Members Online:
3
Guests Online:
86


Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked