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 a module when an URL or a component

Hide a module when an URL or a component

Hi,

I am using JSjobs as component. My template is not so good in the sense that when i use a search module to search a job, the results display in a page of the component i can't control.

My problem is that in this case all the modules of my homepage appear also including the slideshow.

In consequence i was thinking using metamode to hide all the module i don't want to get when displaying the results of my search with Js Jobs modules.

I found out that address is index.php?option=com_jsjobs&c=jsjobs&view=jobseeker&layout=job_searchresults&Itemid=1


Hence, I have written the following in the PHP text area of methamod to make a test:
if ( $option == "com_jsjobs" and $c == "jsjobs" and $view == "jobseeker" and $layout == "job_searchresults" and $Itemid == 1 ) return 47;

If course i want to get the opposite: hide module when getting this url.

So my two problems are the following:

1. my syntax looks bad somewhere since module 47 doesn't appear when reaching this url
2. How to do the opposite ? Hide module when getting this url ?

Regards

coco
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Hide a module when an URL or a component

Hi Coco,

you're on the right track; just need a few adjustments.

1 - you don't get immediate access to all variables in the URL, except the major ones of $option, $view and $Itemid. So you would rewrite your rule above as:

if ( $option == "com_jsjobs"
  and JRequest::getVar("c") == "jsjobs"
  and $view == "jobseeker"
  and JRequest::getVar("layout") == "job_searchresults"
  and $Itemid == 1 ) return 47;

2 - to negate it, you would change all the "==" to "!=", and all the "and" to "or".

e.g.

if ( $option != "com_jsjobs"
  or JRequest::getVar("c") != "jsjobs"
  or $view != "jobseeker"
  or JRequest::getVar("layout") != "job_searchresults"
  or $Itemid != 1 ) return 47;

Alternatively, you can just use an "else" statement with the original:

if ( $option == "com_jsjobs"
  and JRequest::getVar("c") == "jsjobs"
  and $view == "jobseeker"
  and JRequest::getVar("layout") == "job_searchresults"
  and $Itemid == 1 ) return; // note: no module ID returned
else return 47; // so if the above DIDN'T match, then 47 is used.

Hope that helps,
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
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Hide a module when an URL or a component

Hi,
Thank you for help. It apparently doesn't work better.

Are you sure about this code ?

coco
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Hide a module when an URL or a component

try turning on advanced debug mode in MetaMod, then view the page you are targeting, and take a look at the PHP code it produces. Perhaps paste it here for me to have a look at...

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
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Hide a module when an URL or a component

Here is what i get in the metamod module is not submited to search:

Page Identification
The PHP code below may be used to help MetaMod to identify the exact page that you are viewing. For help using this feature, please click here.
if (
$option == 'com_content'
and $view == 'frontpage'
and $Itemid == '1'
and JRequest::getVar('limit') == 1 /*!*/
and JRequest::getVar('layout') == 'default' /*!*/
) return XXX; /* replace XXX with the module ID or position to display */
Note: lines starting with "and" and ending with /*!*/ contain rules that may be optional. You may wish to leave them out.
MetaMod debug info:
$option: com_content
$view: frontpage
$id:
$Itemid: 1
$timezone: default
$language: en-gb
$language_code: en
$language_region: gb
Including modules:


And here is what i get when i perform a search :
Page Identification
The PHP code below may be used to help MetaMod to identify the exact page that you are viewing. For help using this feature, please click here.
if (
$option == 'com_jsjobs'
and $view == 'jobseeker'
and $Itemid == '1'
and JRequest::getVar('uid') == ''
and JRequest::getVar('submit_app') == 'Search Job'
and JRequest::getVar('company') == ''
and JRequest::getVar('jobsalaryrange') == ''
and JRequest::getVar('title') == ''
and JRequest::getVar('isjobsearch') == '1'
and JRequest::getVar('layout') == 'job_searchresults'
and JRequest::getVar('c') == 'jsjobs'
) return XXX; /* replace XXX with the module ID or position to display */
MetaMod debug info:
$option: com_jsjobs
$view: jobseeker
$id:
$Itemid: 1
$timezone: default
$language: en-gb
$language_code: en
$language_region: gb
Including modules: 47

coco
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: Hide a module when an URL or a component

Ok, thanks for those - they make things a lot easier.

Looking at your second one, I think we can strip out some of the options there, and negate it:

if ( ! (
   $option == 'com_jsjobs'
   and $view == 'jobseeker'
   and JRequest::getVar('layout') == 'job_searchresults'
   and JRequest::getVar('c') == 'jsjobs'
) ) return XXX; /* replace XXX with the module ID or position to display */

Now that's starting to look very much like the original one... but that's ok - you confirmed that much from the debug output.

don't forget a few other things:

1 - don't put anything in the "quick module id include" box if you're using a PHP rule like this.
2 - make sure that the target module is disabled. MetaMod will auto-enable it when it includes it (there's an option for that in MetaMod)

Hope that helps,
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
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Hide a module when an URL or a component

If I'd like to display a metamod if the user is not logged in under jomsocial, yet when the user clicks "create account" I then need the module disabled.  How would I do that?

mywebsite.com/community.html - display metamod
mywebsite.com/community/register.html - do not display metamod

your help is appreciated!

zbabyface
Beginner Modder
ranks
useravatar
Offline
5 Posts
User info in posts
Administrator has disabled public posting

Re: Hide a module when an URL or a component

Hi zbabyface,

sorry for the delayed reply. Can you turn on MetaMod Advanced Debug mode, and post the output of the MetaMod when you are viewing the register.html page? There will be information from there that will make it easier to design a rule.

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
3314 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1691
Total Polls:
6
Total Posts:
5912
Total Posts Today:
6
User Info:
 
Total Users:
11515
Newest User:
velis415
Members Online:
0
Guests Online:
148

Online: 
There are no members online

Forum Legend:

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