Author Topic: [Solution Sharing] Breadcrumb Duplicate Cat Prob + Cat (id=1) always display !  (Read 7103 times)

jjj2

  • Jr. Member
  • **
  • Posts: 53
Hi guys I found these solutions by digging thru this forum & some other sites..

A common prob is we will have something weird as redundant category (usually VM will take the 1st category ID=1) to put on the breadcrumb as the parent category. (See attached pictures)
Here's a brief summary to the solution :
http://www.vm-expert.com/index.php?option=com_content&view=article&id=62:use-joomla-menu-for-virtuemart&catid=36:virtuemartexpertblog&Itemid=72

*Note : This solution stil NOT applicable to VM pagination. If you click on the left right VM prod navigation link, the breadcrumb redundant category prob appears again !
If anyone has a solution, please share it here !


Besides this, if you have duplicated categories on the breadcrumb...then try edit the mainframe.class.php file at administrator/components/com_virtuemart/classes

Replace (apprx Line 355):
Code: [Select]
global $mainframe;
With :
Code: [Select]
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;
}

Another Solution is :
Locate : administrator\components\com_virtuemart\classes\mainframe.class.php

Change the function "function vmAppendPathway( $pathway ) {..." by this one :
Code: [Select]
function vmAppendPathway( $pathway ) {
global $mainframe;

// Remove the link on the last pathway item
$pathway[ count($pathway) - 1 ]->link = '';

if( vmIsJoomla('1.5') ) {
$cmsPathway =& $mainframe->getPathway();
/***** YZEDESIGN HACK ******/
$whatinpath=',';
foreach( $cmsPathway->_pathway as $tabpath ) {
$whatinpath.=','.$tabpath->name.',';
}
/***** YZEDESIGN HACK ******/
foreach( $pathway AS $item) {
if (!stripos($whatinpath,','.$item->name.',')){ //********* YZEDESIGN HACK
$cmsPathway->addItem( $item->name, str_replace('&', '&', basename($item->link)) );
}
}
} else {
$tpl = vmTemplate::getInstance();
$tpl->set( 'pathway', $pathway );
$vmPathway = $tpl->fetch( 'common/pathway.tpl.php' );
$mainframe->appendPathWay( $vmPathway );
}
}

[attachment cleanup by admin]

Rasters

  • Beginner
  • *
  • Posts: 3
hmm, I don't know for certain, but I may have come up with a complete fix.  After making these changes (remember to backup the files first!), my menu tracking, breadcrumbs, and paging works perfectly!

I really would like someone to prove me wrong, or at least check the work.  These complaints seemed to have no clear answer and have been a heck of a headache for myself.


Line numbers are approximate.

\administrator\components\com_virtuemart\classes\ps_session.php
(line 459-470, REM out code that gets shopItemID from DB, instead pull it from JRequest)
Code: [Select]
function getShopItemid() {
if( empty( $_REQUEST['shopItemid'] )) {
/*
$db = new ps_DB;
$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");
if( $db->next_record() ) {
$_REQUEST['shopItemid'] = $db->f("id");
*/
if (JRequest::getVar('Itemid')) {
$_REQUEST['shopItemid'] = intval( JRequest::getVar('Itemid'));
} else {


I am also using the VM-Expert Hack I found elsewhere in the forum (also in ps_session.php)
(line 505-554)
Code: [Select]
if( !defined( '_VM_IS_BACKEND' )) {
// Original Virtuemart Code:
// $Itemid = "&Itemid=".$this->getShopItemid();
// VM-Expert Hack – Start

// Strip the parameters from the $text variable and parse to a temporary array
$tmp_text = str_replace('amp;','',substr($text,strpos($text,'?')));
if(substr($tmp_text,0,1)=='?') $tmp_text=substr($tmp_text,1);
parse_str($tmp_text,$ii_arr);

// Init the temp. Itemid
$tmp_Itemid='';

$db = new ps_DB;

// Check if there is a menuitem for a product_id (highest priority)
if (isset($ii_arr['product_id'])) {
$ii_product_id=intval($ii_arr['product_id']);
$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%product_id=$ii_product_id%' AND published=1");
if( $db->next_record() ) $tmp_Itemid = $db->f("id");
}
// Check if there is a menuitem for a category_id
if (isset($ii_arr['category_id'])) {
$ii_cat_id=intval($ii_arr['category_id']);
if ( $ii_cat_id && $tmp_Itemid=='') {
$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%category_id=$ii_cat_id%' AND published=1");
if( $db->next_record() ) $tmp_Itemid = $db->f("id");
}
}
// Check if there is a menuitem for a flypage
if (isset($ii_arr['flypage'])) {
$ii_flypage=$ii_arr['flypage'];
if ($ii_flypage && $tmp_Itemid=='') {
$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%flypage=$ii_flypage%' AND published=1");
if( $db->next_record() ) $tmp_Itemid = $db->f("id");
}
}
// Check if there is a menuitem for a page
if (isset($ii_arr['page'])) {
$ii_page=$ii_arr['page'];
if ($ii_page && $tmp_Itemid=='') {
$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%page=$ii_page%' AND published=1");
if( $db->next_record() ) $tmp_Itemid = $db->f("id");
}
}
// If we haven't found an Itemid, use the standard VM-Itemid
$Itemid = "&Itemid=" . ($tmp_Itemid ? $tmp_Itemid : $this->getShopItemid());

// VM-Expert Hack - End
}


\administrator\components\com_virtuemart\classes\mainframe.class.php

(line 363, REM it out ...this was where the double breadcrumb problem starts!)
Code: [Select]
// $cmsPathway->addItem( $item->name, str_replace('&', '&', $item->link) );

jackstraw

  • Beginner
  • *
  • Posts: 1
i applied jjj2's second solution ( "change the function "function vmAppendPathway" ) for duplicate categories and it worked brilliantly! Thanks jjj2 

aaronzy

  • Beginner
  • *
  • Posts: 4
Thank you guys!

I had similar problem.  As described in my thread http://forum.virtuemart.net/index.php?topic=59491.0

Quote
Hi everybody,

I'm new to virtuemart.  I made a website using joomlar 1.512 and virtuemart 1.1.3 for my friend's company.

I also installed sh4.4SEF 1.0.20_Beta - build_237 to make the urls search engine friendly.

Since it's a manufacturer's website, I have disabled all virtuemart's cart functions and used it as a online catalogue.

In "main menu", "Our products" is the store link.  Below the "Our products", There are ”Submenu leve 2 a", "Submenu level 2 b", Submenu level 2 c", etc.  And below "Submenu level 3 a", there are "Submenu level3 a", "Submenu level 3 b".

The weird problem I encounter is that when I click on all the level 2 submenus, the breadcrums are ok.  But when I click on the level 3 submenus, the breadcrums will be like"Home-Our products-Sub menu level 2-Submenu level 3-Submenu level 2".

You can click on this link to see the problem, http://www.chinawaterdispenser.com/Non-gall-Water-Dispenser.html

And here is the screenprint.

Thank you for any advice!

Quote
jjj2 listed two solutions.  I tried the first one, and the breadkcrum problem of my level 3a menu disappeared.  But the other level 3 menu still had the problem.

I tried the second solution, and the breadcrum problem disappeared in my other level 3 menu, but it still exists with other menus.

That's really weird.