Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » Displaying a Module for a particular...
Displaying a Module for a particular Category in Mosets Tree
Displaying a Module for a particular Category in Mosets Tree
Hey Stephen,
Ok, so is there a formula that I have missed that will check for a particular variable in Mosets Tree? For example, I want to display a module for the category of the listing shown. There are two tables one is u62_STmaster_mt_links and u62_STMaster_mt_cl that are joined by link_id. I want to do something that says if cat_id='899' then display module 292. Is it possible to access that information from metamod???
Thanks again for all of your help and btw, with all this great support for recipes, why don't you have a Donate Now button so we can help cover your time spent on this great product??? I would certainly make a donation!
Sondra
08-Feb-10 15:25:17
Re: Displaying a Module for a particular Category in Mosets Tree
Hi Sondra,
thanks for the donation offer... perhaps I should replace those under-performing Google ads in the right column with a donate button? Sounds like a good idea.
Regarding Mosets tree - can you be a bit more specific about the URL for the page, and the exact column names in the 2 tables you mentioned? Which of the tables has a column that matches the value in the URL? (and which URL parameter does it match)?
Cheers,
Stephen
Re: Displaying a Module for a particular Category in Mosets Tree
Ok if you follow this link
http://www.e-ferred.com/georgia/index.p … Itemid=324
You will see the Category 1050 which is Suwanee (a City in Georgia)
Then if you click The River Club, you will see this link
http://www.e-ferred.com/georgia/index.p … Itemid=324
which is a Community in Suwanee.
The two tables I mentioned before (...mt_cl and ...mt_links) are joined by the link_id which is auto-generated when the user enters a new listing in Mosets Tree. The user selects the category when the listing is saved. The parameters are set so that only one category can be chosen.
I am trying to show a module when the cat_id = to the city that has been selected. For example a weather module - when the cat_id indicates it is Suwanee, show the weather for Suwanee. Does this make sense? What I am doing is much more complicated then that but if I could do something this simple, I think I could finish the rest on my own.
Thanks again! Love the donate button!
Sondra
Re: Displaying a Module for a particular Category in Mosets Tree
OK, makes sense.
Try this:
if ($option == 'com_multisites' and JRequest::getVar('task') == 'viewlink') {
$link = JRequest::getInt('link_id',0);
$query = 'select cat_id from #__STMaster_mt_cl where link_id = $link;';
$db->setQuery( $query, 0, 1 );
$row = $db->loadObject();
$cat_id = @$row->cat_id;
if ($cat_id == 55) return 101; // module 101 for category 55
// add more as appropriate
}
Re: Displaying a Module for a particular Category in Mosets Tree
Hey Stephen,
I have just made my way to utilizing the code you provide above, however, it isn't working. I thought I had found the problem with the mtree as opposed to multisites, but I am still unable to retrieve a cat_id value.
I'm using the following just to determine where the problem is and I'm not getting any value to display at all as the $cat_id but the $linkid is displaying correctly. No error messages, just no $cat_id.
if ($option == 'com_mtree' and JRequest::getVar('task') == 'viewlink') {
$link = JRequest::getInt('link_id',0);
$query = 'select cat_id from u62_STmaster_mt_cl where link_id = $link;';
$db->setQuery( $query, 0, 1 );
$row = $db->loadObject();
$cat_id = @$row->cat_id;
echo "welcome to";
echo $cat_id;
echo $link;
}
Also, is there a way to use a global variable for the site prefix so that I don't have to hard code it???
Thanks so much!
Sondra
Re: Displaying a Module for a particular Category in Mosets Tree
Hi Sondra,
for the site prefix, yes there's a way to do that. Instead of jos_ or u62_, use #__ (# followed by two underscores).
WIth regard to the recipe, try turning on Advanced Debug mode, and make sure that it is suggesting the same variables that you are using (I think it probably is, since you're getting output from $link). Then go direct to your database and see what happens when you do exactly the same query as used in the recipe. Does it come up with the right value, or an error?
Cheers,
Stephen
Re: Displaying a Module for a particular Category in Mosets Tree
Ok with the variable &link not being defined in Navicat, I used the following sql for the query
select cat_id from u62_STmaster_mt_cl where link_id = '351'
and it returned
1050
which is correct. Any ideas????
Re: Displaying a Module for a particular Category in Mosets Tree
OH! I see it now. It's all about single and double quotes.
You were using:
$query = 'select cat_id from u62_STmaster_mt_cl where link_id = $link;';
However, when you use single quotes like this, then any $ variables inside the quotes DO NOT get converted to their real values.
If you use double quotes, then it works as you would expect.
So try this instead:
$query = "select cat_id from u62_STmaster_mt_cl where link_id = $link;";
Cheers,
Stephen
Re: Displaying a Module for a particular Category in Mosets Tree
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » Displaying a Module for a particular...
Board Info
- Board Stats:
- Total Topics:
- 1699
- Total Polls:
- 6
- Total Posts:
- 5967
- Total Posts Today:
- 2
- User Info:
- Total Users:
- 8028
- Newest User:
- musial8334
- Members Online:
- 0
- Guests Online:
- 229
- 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