News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Show module ONLY on homepage of VM2

Started by nflmerch, December 13, 2011, 23:35:57 PM

Previous topic - Next topic

nflmerch

J 1.7
VM2  RC 3 K

I'm having trouble getting a module to show up ONLY on my homepage.
My homepage is the VM Default Layout, assigned to a joomla menu item as the default page.

When I use a module's Menu Assignment parameter, and I set it to show only on homepage, the module still shows up on all Virtuemart pages including product detail pages.
(but when I navigate to any page outside of VM, the module does not show up as desired.)

I've tried this code in my template:

$menu = JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo '<div id="pathway"><jdoc:include type="modules" name="position4" /></div>'; }

But it still sees the homepage as EVERY virtuemart page, and places the module on every VM page.


I've also tried the old code for $option = 'com_virtuemart' but it gives an error because I believe VM2 doesn't use the  $option  variable anymore:

if($option=='com_virtuemart') {}else{
   echo '<div id="pathway"><jdoc:include type="modules" name="position4" /></div>';}


Can anyone help me with what I'm doing wrong?  Or perhaps someone knows the new varible that replaced $option
Thanks

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

PRO

#2
This will work
<?php if (JRequest::getVar('view')=='virtuemart') { ?>
<jdoc:include type="modules" name="module" />
<?php } ?>


extra, create a module position for each category

<?php if (JRequest::getVar('view')=='category') { ?>
<jdoc:include type="modules" name="catfoot<?php echo JRequest::getInt('virtuemart_category_id',0); ?>" />
<?php } ?>

This will create a module position name catfoot(categoryid)

You could do the same with each product


<?php if (JRequest::getVar('view')=='productdetails') { ?>
<jdoc:include type="modules" name="productfooter<?php echo JRequest::getInt('virtuemart_product_id',0); ?>" />
<?php } ?>

http://www.kaizenmediaworks.com/virtuemart-template-and-module-control

nflmerch


VM_Fans

I'm just trying to test VM2 and have the same issue. Thanks for the tips.

tobisagt

#5
Quote
This will work
<?php if (JRequest::getVar('view')=='category') { ?>
<jdoc:include type="modules" name="module" />
<?php } ?>

Thats it what I was searching for! It works, but not perfect for me.

It just works i if i click to an category in the mainmenu.
The URL: http://localhost/cvbpaderborn/index.php?option=com_virtuemart&view=category&virtuemart_category_id=6&Itemid=105

If i go that way: Frontpage (top products, latest... etc.) -> Product -> Use Breadcrumbs to go into the product category -> it dont show the moduleposition
The URL: http://localhost/cvbpaderborn/index.php?option=com_virtuemart&view=category&virtuemart_category_id=6 (no itemid)

So, the itemid is the solution. It would be nice if someone tell me how to fix it?  :-\

Thx.
Tobi

PRO

Quote from: tobisagt on January 06, 2012, 00:37:05 AM

So, the itemid is the solution. It would be nice if someone tell me how to fix it?  :-\

Thx.
Tobi

this code

<?php if (JRequest::getVar('view')=='category') { ?>
<jdoc:include type="modules" name="module" />
<?php } ?>

will show the module anytime this  &view=category

is in the url. with or without the itemid.


lipes

#7
- In my index page i got the Mod Featured Product active with some products.
If i click to go to Virtuemart Area Main Categorie ( index.php?option=com_virtuemart ) or if i click in the 1st Categorie (index.php?option=com_virtuemart&view=category&virtuemart_category_id=1) I cant  see any left module (that i had applied ( assigned to all pages )

BUT If i click on the Menu item that i've assined for some Categorie Name item ( index.php?option=com_virtuemart&view=category&virtuemart_category_id=1&Itemid=135 ) NOW i can see the module VM Categorie on the left side, and the SubCategories Images on the Right side ..

- If i click on any product in Index page i cant see any module on left side too (in product area)...

<?php $menu = &JSite::getMenu();
if (
$menu->getActive() != $menu->getDefault()) { ?>

<div class="lateral"><jdoc:include type="modules" name="lateral" /></div>
<?php ?>

with this code i can have the module in left side.. but it displays in all joomla articles, etc... and i just wanna to apply this left module in Virtuemart Area ...

I also tryed to add the code {module 170} of Modules Anywhere in some VM default.php files..
components\com_virtuemart\views\virtuemart\tmpl
components\com_virtuemart\views\productdetails\tmpl
\components\com_virtuemart\views\category\tmpl
\components\com_virtuemart\views\categories\tmpl

but without sucess... :/
There is any way to hide the module from index.php and add it only in VM area ?
Thanks

update: solved by done some experiences .. lol but i dont understant nothing of php, this works for now (hope this could help many members..)
<?php  if(!($_GET['view'] !== 'frontpage' ) or JRequest::getCmd( 'option' )=='com_virtuemart'): ?><div class="lateral"><jdoc:include type="modules" name="lateral" /></div><?php endif; ?>
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

PRO

Quote from: lipes on March 30, 2012, 03:11:29 AM
<?php  if(!($_GET['view'] !== 'frontpage' ) or JRequest::getCmd( 'option' )=='com_virtuemart'): ?><div class="lateral"><jdoc:include type="modules" name="lateral" /></div><?php endif; ?>

$_GET   is NOT what you want.

JRequest is Joomla's API for protection.

Modules an ALL virtuemart pages

<?php if (JRequest::getCmd('option')=='com_virtuemart') { ?>
<div class="lateral"><jdoc:include type="modules" name="lateral" /></div>
<?php } ?>


lipes

BanquetTables.pro, thanks for your explanation and correction. I changed the code right now.

Unfortunately I did not want the module at all Virtuemart Areas... but its the better that we can do, right?
I dont want that left side Module (VM categories) on the User Registration page, and in the VM Manufacturer Module, or in the Checkout page.... :S

but its the better that we can do/have, correct?

Tks
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

PRO

Quote from: lipes on March 30, 2012, 15:02:07 PM
BanquetTables.pro, thanks for your explanation and correction. I changed the code right now.

Unfortunately I did not want the module at all Virtuemart Areas... but its the better that we can do, right?
I dont want that left side Module (VM categories) on the User Registration page, and in the VM Manufacturer Module, or in the Checkout page.... :S

but its the better that we can do/have, correct?

Tks

what pages do you want it on?

for vmart frontpage the 'view'=virtuemart


lipes

#11
I want to apply in all VM Product Categories (or Category) and in all VM Products Details.. not in joomla articles, etc, or in the joomla index page.

(for me) displaying the Mod VM Categories in places like joomla articles, index, Cart, VM Manufacturer Logos Page, Registration area, etc.. doesnt make any sense, because my top Main menu already display that principal categories items too.


Yes I've got the joomla frontpage active not the virtuemart index in default :)
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

PRO

Quote from: lipes on March 30, 2012, 16:11:42 PM
I want to apply in all VM Product Categories (or Category) and in all VM Products Details.. not in joomla articles, etc, or in the joomla index page.

(for me) displaying the Mod VM Categories in places like joomla articles, index, Cart, VM Manufacturer Logos Page, Registration area, etc.. doesnt make any sense, because my top Main menu already display that principal categories items too.


Yes I've got the joomla frontpage active not the virtuemart index in default :)


They are all right here.
http://www.kaizenmediaworks.com/virtuemart-template-and-module-control


You can always go like this

<?php if (JRequest::getVar('view')=='productdetails') Or (JRequest::getVar('view')=='categories') Or (JRequest::getVar('view')=='category') { ?>
<jdoc:include type="modules" name="module-name" />
<?php } ?>

I THINK thats the right syntax

lipes

#13
update: <?php if (JRequest::getVar('view')=='productdetails') Or (JRequest::getVar('view')=='categories') Or (JRequest::getVar('view')=='category') { ?>
<div class="lateral"><jdoc:include type="modules" name="lateral" /></div>
<?php } ?>

give me this: Parse error: syntax error, unexpected T_LOGICAL_OR  



update: with this works fine
<?php if (JRequest::getCmd('option')=='com_virtuemart') if (JRequest::getVar('view')=='productdetails') if (JRequest::getVar('view')=='categories') if (JRequest::getVar('view')=='category') { ?>
<div class="lateral"><jdoc:include type="modules" name="lateral" /></div>
<?php } ?>
i've changed the word 'or' to 'if' ...


new update from last update: now i've clean the cache and dont work.. argh!

new update from the many others updates (lol):   :)
<?php if (JRequest::getVar('view')=='category' or JRequest::getVar('view')=='productdetails' or JRequest::getVar('view')=='categories') { ?>
<div class="lateral"><jdoc:include type="modules" name="lateral" /></div>
<?php ?>



Many thanks
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

lipes

Now i've found one problem....

JRequest::getVar('view')=='category'

works for blog area Joomla Category and Virtuemart Product category too ... the module is displayed (at left side) in this two areas.  :-X

VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25