0

i'm working on a joomla 1.5 for a university project (when it started 2.5 wasn't out :D). What i'm trying to do is to assign a module to my custom component , but not every page of it. The 2 different pages of my component is a page that shows every product , but the other one needs an id to work. In order to assign the module just to a page i think i need to assign every page my component has to a menu item. But my problem is that i don't know how to assign my page that shows a specific product the variable id to make it work.

Elatar
  • 3
  • 3
  • You could wrap the module in a php if statement that checks something like the following: `if (JRequest::getVar('option') == 'your_component' && JRequest::getVar('view') != 'view_without_module') { then display module; }` – David Fritsch Aug 06 '13 at 16:12

3 Answers3

0

One method would be to set the module to be hidden on that page using CSS.

Go to views/view_name/tmpl/default.php and within the tags at the top, add the following code in:

$doc = JFactory::getDocument();
$doc->addStyleDeclaration(" #element_id { display: none; } ");

You will need to inspect the module using a tool such as Firebug, Chrome Dev Tools or another tool depending on which browser you're using, and change element_id to whatever suits your needs.

Hope this helps

Lodder
  • 19,758
  • 10
  • 59
  • 100
  • Since it's a university project i'm trying to do make everything the 'right' way. So i'd prefer a solution that doesn't hide it and makes it so it doesn't even load. Thanks for the effort though! – Elatar Aug 06 '13 at 15:51
0

The Joorthodox way, i guess, would be to control the module availability from the module manager in administator page, where you can assign it to certain pages/menu items only. Thus summarizing, create a menu item type for that page assign it to a menu item which in turn will be your module control switch for that page.

Another approach could be a control directly to the joomla module renderer. An example can be found here: joomla-is-there-a-module-render-plugin-event

Community
  • 1
  • 1
angelo bodas
  • 98
  • 1
  • 6
  • But how am i going to make that menu item to work with the id?? – Elatar Aug 06 '13 at 17:20
  • You dont have to, your link could be assigned to the page by your module or component to an appropriate html element. The menu item will only be used by the module manager to see which view corresponds to that link and if it is going to enable it. Menu item can even stay unpublished – angelo bodas Aug 06 '13 at 18:09
  • I've enabled seo links and i think that's what screwing me up. Also the unpublished menu item doesn't show up at module page selection. – Elatar Aug 06 '13 at 18:21
  • Thought it would be ok unpublished, since it's working on 2.5, sorry. That is not our main problem anyway. Try creating a menu item type for that view, a default.xml in the tmpl folder of your component's view, an example can be found here http://stackoverflow.com/questions/8673154/joomla-component-not-appearing-in-the-menu-item-types?rq=1, and try to assign it to a new menu item. – angelo bodas Aug 07 '13 at 16:48
  • But won't that create a menu item for a single product id?I'm trying to achieve is a link as a submenu of my component to block the module i don't want to the single products(but still having it enabled at the list of products).I've used .xml for my list of views to add a parameter and the single shows up as a menu item.But when i'm chosing the single menu item it's of course not displaying anything cause it has no id but also it blocks the site from displaying every single product as well , even though the displayed link is correct. That's why i think my seo is getitng into the way there. – Elatar Aug 07 '13 at 23:14
  • The menu item will be used by the module manager to enable or disable the module on that page(view,ie &view=products), does not care about extra parameters (in your case product id)(you can hide the menu item with css if you dont want it to be shown up). To get to that page just create the appropriate hyperlink tags at your own convenience. It wont matter if you go to that page through a custom hyperlink tag (which you will) or a menu item, as long as the renderer sees that you're on that view the module is set to be disabled. As for seo, im not sure. – angelo bodas Aug 08 '13 at 06:42
0

Just use Advanced Module Manager and assign your module by URL's not just by the menu link, it works for me to hide and show a module inside the different pages of the same component

Alaeddine
  • 6,104
  • 3
  • 28
  • 45