Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » [solved] enable / disable modules by...
[solved] enable / disable modules by user
[solved] enable / disable modules by user
Hi,
First of all let me say how brilliant we have found MetaMod to be.
We have been using MetaMod Pro 3.11 with the recipe below on our Joomla 2.5 site which is working great.
What I am trying to do is add to the code so that in addition to enabling a module it will disable another so in effect replace one module with another.
Any help would be very much appreciated.
// change some_guy23 to the login name of the person you are tracking
$search_user_name = 'some_guy23';
$username = $db->getEscaped($search_user_name);
$query = "SELECT username "
. " FROM jos_session WHERE username = '$username' "
. " AND guest = 0 "
. " AND client_id = 0 ;" ;
$db->setQuery( $query );
$found = $db->loadAssoc();
if (is_array($found)) return 101; /* found him. customise to your own module number. */
return 102; /* didn't find him. Customise to your own module number. */
31-Dec-13 07:40:22
Re: [solved] enable / disable modules by user
Hi philkin,
In this case what I'd do is to disable BOTH of the modules that you want to control, e.g. by setting them to a nonexistant module position or to menu items: none.
Then use exactly the code above, customising only the 101 and 102 to be the module ids of the 2 modules. The effect is that the 1st one will be shown when some_guy23 is logged in, and the 2nd one will be shown if he is NOT logged in.
Best regards,
Stephen
Re: [solved] enable / disable modules by user
Hi Stephen,
Thank you for your quick reply.
I have already tried your suggestion but the problem is we have multiples of MetaMod running to monitor for various users logged in so we end up with lots of copies of module 102 being displayed if non of the users are online.
We use MetaMod to control a profile photo of a radio station presenter, there are 30 users / profiles to display so Metamod tracks who is logged in at the studio and will display there photo but if the system is running on recordings then an automated schedule will be displayed.
Regards
Phil
Re: [solved] enable / disable modules by user
Hi Phil,
Oh, I see what you mean. If you are using the Pro version of MetaMod, you can do the following to disable a given module:
$changes->mod(102)->disable();
So the entire code block you specified above could be rewritten like this:
// change some_guy23 to the login name of the person you are tracking
$search_user_name = 'some_guy23';
$username = $db->getEscaped($search_user_name);
$query = "SELECT username "
. " FROM jos_session WHERE username = '$username' "
. " AND guest = 0 "
. " AND client_id = 0 ;" ;
$db->setQuery( $query );
$found = $db->loadAssoc();
if (is_array($found)) {
$changes->mod(102)->disable(); /* gets rid of this module if it exists */
return 101; /* and display this module */
}
Note that MetaMod Pro is the paid version. The mechanism I am suggesting here does not work on the free version, as the free version can only affect modules that the MetaMod itself includes (whereas the Pro version can affect any module on the page using the $changes->mod(XXX)->... mechanism).
I hope that helps,
Happy New Year,
Stephen
Re: [solved] enable / disable modules by user
Stephen,
Thank you very much for first class support.
that code seems to works great, I will test it fully over the next few days but the quick check I have just had works fine.
We are using the Pro version & I have to say it is one of the best extensions we have added to our website.
Kindest Regards
& Happy New Year
Phil
- Index
- » MetaMod
- » MetaMod General Support
- » [solved] enable / disable modules by...
Board Info
- Board Stats:
- Total Topics:
- 1699
- Total Polls:
- 6
- Total Posts:
- 5967
- Total Posts Today:
- 2
- User Info:
- Total Users:
- 8027
- Newest User:
- henley7346
- Members Online:
- 1
- Guests Online:
- 169
- Online:
- henley7346
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked