News:

Looking for documentation? Take a look on our wiki

Main Menu

Bug: Duplicated breadcrumbs

Started by doorknob, June 07, 2009, 04:13:52 AM

Previous topic - Next topic

doorknob

VM adds text to the standard Joomla breadcrumbs to create a bespoke vm breadcrumb set. This works fine when the vm module is used to simulate a menu because vm starts with the breadcrumbs for its own 'home' page and then adds the product category and product name strings to create the final breadcrumbs. This breaks down if 'VirtueMart' menu items are used. In this situation, VM uses the actual id of the menu item as the start point for the breadcrumbs and then adds more strings that duplicate the values created by Joomla. I have fixed this by changing mainframe.class (line 391 in build 1760) from:
global $mainframe;

to:
global $mainframe, $sess;

// Only add the extra pathway if the menu item is using the default VM Itemid
$Itemid = $_REQUEST['Itemid'];
if( $Itemid && $Itemid != $sess->getShopItemid() ) {
return;
}


Regards
Phil

chrism

Phil,

Thank you, i have implement the change above and it has fixed my duplicate breadcrumbs issue.

My change was on line 355 as i say it works so it must be the same...

\administrator\components\com_virtuemart\classes\mainframe.class line 355 directly under
function vmAppendPathway( $pathway ).

Thanks again, very good work (which should go into the next release)
Chris
Chris
www.getupandgrow.com online store and more....

chrism

Phil,

I notice now that when in an items flypage, the item itself is no longer in the breadcrumb and the category which is now the last breadcrumb has no link. I would like it the item still to be present and a link back to the category, is this possible? I am still very appreciative of the fix ;-)

Thanks
Chris
Chris
www.getupandgrow.com online store and more....

doorknob

Chris,
The principle behind my mods to breadcrumbs is:
1 Use the Joomla default approach when the page corresponds to a menu item (i.e. the item has its own menu item and the url does not include 'Itemid=xx' where xx is the item id of the VM 'home' page)
2 Use the VM function to generate the breadcrumbs when the page is not mapped directly to a menu item. Usually, product detail pages don't have menu items (not on my site).

If the product detail pages have breadcrumbs that don't include the product name then the page is considered to have its own Itemid and the Joomla breadcrumbs are being displayed instead of the VM breadcrumbs. To get the vm breadcrumbs, the page must be recognised as not having its own menu item. Take a look at this post http://forum.virtuemart.net/index.php?topic=56531.0.
Regards
Phil

chrism

Phil,

Thanks again your previous post explains why i am seeing what i'm seeing, i have previously implemented http://forum.virtuemart.net/index.php?topic=42931.msg162939#msg162939
which enabled me to keep focus on my VM menu items even when displaying a details page, i did this so that i could control the modules that are displayed in individual categories/flypages. Keep up the good work, i appreciate, and i'm sure many others will appreciate your work.

Thanks
Chris
Chris
www.getupandgrow.com online store and more....

vmfan

Quote from: doorknob on June 07, 2009, 04:13:52 AM
VM adds text to the standard Joomla breadcrumbs to create a bespoke vm breadcrumb set. This works fine when the vm module is used to simulate a menu because vm starts with the breadcrumbs for its own 'home' page and then adds the product category and product name strings to create the final breadcrumbs. This breaks down if 'VirtueMart' menu items are used. In this situation, VM uses the actual id of the menu item as the start point for the breadcrumbs and then adds more strings that duplicate the values created by Joomla. I have fixed this by changing mainframe.class (line 391 in build 1760) from:
global $mainframe;

to:
global $mainframe, $sess;

// Only add the extra pathway if the menu item is using the default VM Itemid
$Itemid = $_REQUEST['Itemid'];
if( $Itemid && $Itemid != $sess->getShopItemid() ) {
return;
}


Regards
Phil

Thanks, thanks, thanks, thanks, 

THOUSAND THANKS

I searched so long to a solution....


Exuse my English...it´s not so good ....

Regards
Brigitte

dylanjh

Hmmmmmmph! When I make the change it tells me "PHP Fatal error:  Call to a member function getShopItemid() on a non-object in /var/www/html/sigma/administrator/components/com_virtuemart/classes/mainframe.class.php on line 358"

Any ideas people?
Register in Joomla / Virtuemart without a Username (uses email address instead). http://www.lunarhotel.co.uk

doorknob

Looks like you didn't declare $sess as a global or mistyped the variable name.

getShopItemid is a method of the $sess object. This object is created by VM as part of the standard VM environment and declared as a global variable. $sess therefore already exists but to use it you must make sure that it has been declared as a global in the function where it is to be used.

Good luck
Phil

Forrest

Quote// Only add the extra pathway if the menu item is using the default VM Itemid
      $Itemid = $_REQUEST['Itemid'];
      if( $Itemid && $Itemid != $sess->getShopItemid() ) {
         return;
      }

Yes, right above this add:
global $sess;

So the final should be:

// Only add the extra pathway if the menu item is using the default VM Itemid
      $global $sess;
      $Itemid = $_REQUEST['Itemid'];
      if( $Itemid && $Itemid != $sess->getShopItemid() ) {
         return;
      }

doorknob

QuoteSo the final should be:

// Only add the extra pathway if the menu item is using the default VM Itemid
      $global $sess;
      $Itemid = $_REQUEST['Itemid'];
      if( $Itemid && $Itemid != $sess->getShopItemid() ) {
         return;
      }

The original post does include this (added into the existing global statement)

Forrest

Hmmm, late night I guess. Not as smart as a doorknob :( Thanks.

randomperson

#11
is this going to get fixed in the official release or something...?

by the way, this `fix` creates a new issue, when browsing for the product itself it won't display breadcrumb for it at all (when there is a joomla menu assigned to the specific category)

doorknob

Quoteby the way, this `fix` creates a new issue, when browsing for the product itself it won't display breadcrumb for it at all (when there is a joomla menu assigned to the specific category)
Works OK on my site. Take a look here http://www.eyeforabargain.co.uk/Bargains-Bazaar/Newfix-Car-Seat-Panama.html for example.

kelsay

Hi doorknob!  Sorry to intrude on this thread...

I too have a problem with my breadcrumbs not being okay.
They are fine for most pages and products, except the My Account and CART links are not.
I get HOME -> CATEGORY -> CART while it should say  HOME -> CART.

I have tried to find " $Itemid = $_REQUEST['Itemid'];" in my mainframe.class.php but it is not there. I'm using 1.5.20 and 1.1.15.

Can you help me with this?




doorknob

QuoteI have tried to find " $Itemid = $_REQUEST['Itemid'];" in my mainframe.class.php but it is not there
The mod I posted was designed to change the way that the breadcrumbs are generated when a page is linked to a menu item. VM links every page to its own home page by using the $sess->getShopItemid() function (although that function has a bug because the sql it uses is not sufficiently selective in all cases). If, like me, you want to be able to use the Joomla security and configuration features that are associated with menu items, rather than treay the whole of VM as a single page then it is necessary to make the change I posted. The "$Itemid = $_REQUEST['Itemid'];" code identifies the itemid associated with the menu item that called the current page and is not the way that VM usually works.

I don't use the cart and so I can't replicate your issue. Unless your cart is linked to a menu item then I would not expect this patch to be responsible. If it is linked to a menu item, I suggest that you include Itemid=nn in the menu item url, where nn is the itemid of the VM home page (find the id of your main vm menu item in the menu editing area). If you are using sef, don't forget to clear the cache.
Regards
Phil