Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
module in a category K2
module in a category K2
Hello
I want to apparaire a module in a category K2
and another module in an article k2
I try but without success
Can you help me and give me the code to place two
thank you
...........................
the solution was in the forum
here the
Si ()
option $ == « com_k2 »
vue $ == « itemlist »
et JRequest::getVar('task') == « catégorie »
) {
$catid = (int)$ id ;
Si ($ catid == 1) return XXX ;
Si ($ catid == 2) Retour YYY ;
/ / etc.
}
Remplacez XXX et YYY avec les ID de module à utiliser pour les chats 1 et 2. Personnaliser comme il convient.
-uniquement sur toutes les pages de la catégorie :
Si ()
option $ == « com_k2 »
vue $ == « itemlist »
et (JRequest::getVar('layout') == « catégorie » ou JRequest::getVar('task') == « catégorie »)
) Retour XXX ; / * Remplacez XXX le ID de module ou la position d'affichage *
04-Feb-12 01:14:10
Re: module in a category K2
Note to anyone reading: the translation software has translated all the PHP code into French, which obviously doesn't work in PHP. I think the code above probably originally read:
Code:
if ( $option == "com_k2"
and $view == "itemlist"
and JRequest::getVar('task') == "category"
) {
$catid = (int)$ id ;
if ($catid == 1) return XXX ;
if ($catid == 2) return YYY ;
// etc
}
Code:
if (
$option == "com_k2"
and $view == "itemlist"
and (JRequest::getVar('layout') == "category" or JRequest::getVar('task') == "category")
) return XXX; /* Remplacez XXX le ID de module ou la position d'affichage */
Re: module in a category K2
Hi snibble,
yes, it can, but it needs a database query, like this:
if (
$option == 'com_k2'
and $view == 'item') {
$db->setQuery(
'select catid '
. 'from #'
. '__k2_items '
. 'where id = ' . (int)$id);
$cat = $db->loadResult();
if ($cat == 1) return XXX;
if ($cat == 2) return YYY;
if ($cat == 3) return ZZZ;
// replace XXX, YYY, ZZZ with the module ids to return for each category.
// add more as appropriate.
}
Re: module in a category K2
Hello. Is it possible to combine both code snippets you've provided here into one metamod? I am trying to have a module display both on the category itemlist view, and the individual item view for the category IDs that I am targeting.
For example I want to include a house advert in the 'Bathrooms' and 'Kitchens' category pages, as well as all article items within 'Bathrooms' or 'Kitchens' on my site.
Re: module in a category K2
Sure, try this:
$catid = null;
if (
$option == "com_k2"
and $view == "itemlist"
and (JRequest::getVar('layout') == "category" or JRequest::getVar('task') == "category")
) {
$catid = (int)$id;
} else if (
$option == 'com_k2'
and $view == 'item') {
$db->setQuery(
'select catid '
. 'from #'
. '__k2_items '
. 'where id = ' . (int)$id);
$catid = $db->loadResult();
}
if ($catid == null) return; // we didn't find the catid - short circuit.
if ($catid == 1) return XXX ;
if ($catid == 2) return YYY ;
// replace XXX and YYY with the module ids to return for cat 1 and cat 2,
// and add more lines as appropriate.
Cheers,
Stephen
Re: module in a category K2
Hello,
I am trying to get several modules to appear above the content of a K2 category and NOT on the item pages that are in the category.
It seemed to work for a while without me installing any fixes but now all the modules assigned to the K2 category page show up on the item pages.
I am not having any luck with your module using the Quick module id field or any of the code above. With your module I was able to get the modules to show up on the category page but they still show up on the item page.
I am not a php programer so any help would be greatly appreciated.
Re: module in a category K2
Since this thread was created, there has been some new code added to MetaMod to make it easier to handle K2 page types.
Try this:
1 - remove anything from the Quick Module Id box
2 - make sure the "Target" module (the one you want the MetaMod to display) is assigned to a fake module position, or to "menu items: none" so that it does not display until the MetaMod includes it
3 - use the following PHP code in the MetaMod:
$k2 = JomGenius("k2");
if ($k2->info("pagetype startswith category")) return XXX;
// replace XXX with the module id of the module you want to display on K2 category pages.
I trust that helps,
Stephen
Re: module in a category K2
Hi Stephen,
I tried following your instructions but it does not seem to be working for me.
Per your instructions, I set the mod position to xxx (xxx is a fake position) and set it to display on none, and then tried all pages but nothing shows up. Then I put the module id in the Quick Module Id box and it shows up along with the MetaMod title (Because I have it set to show title) in the proper position and page but also on the K2 item page.
Any other suggestions?
Thank you,
Mike
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Total Posts Today:
- 1
- User Info:
- Total Users:
- 7623
- Newest User:
- laptopreviews21
- Members Online:
- 0
- Guests Online:
- 127
- 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