Virtuemart Pathway - Why is it not working?
July 1st, 2006After installing Virtuemart, a highly integrated shopping cart for Joomla!, I realized that there was a small issue. The issue was with how Virtuemart and Joomla displayed the pathway of the cart. When looking at the product it displayed the a double pathway and with most of the links not working. While browsing a category you couldn’t go back to the main store because the link was not linkable. This was very annoying to me and after hours of figuring out what was going and going through code pieces I collaborated on a bunch of various different hacks and this is what ended up working for me and has been tested on all versions of Joomla and only with Virtuemart 1.0.5.
Open up the following file in your favorite editor: /administrator/components/com_virtuemart/classes/ps_product_category.php
Find the following code:
function get_navigation_list($category_id) {
global $sess, $mosConfig_live_site;
$db = new ps_DB;
static $i=0;
static $html = "";
$q = "SELECT category_id, category_name,category_parent_id FROM #__{vm}_category, #__{vm}_category_xref WHERE ";
$q .= "#__{vm}_category_xref.category_child_id='$category_id' ";
$q .= "AND #__{vm}_category.category_id='$category_id'";
$db->setQuery($q); $db->query();
$db->next_record();
if ($db->f("category_parent_id")) {
$link = "url($_SERVER[’PHP_SELF’] . “?page=shop.browse&category_id=$category_id”);
$link .= “\”>”;
$link .= $db->f(”category_name”);
$link .= ““;
$category_list[$i++] = ” “.$this->pathway_separator().” “. $link;
$this->get_navigation_list($db->f(”category_parent_id”));
}
else {
$link = “url($_SERVER[’PHP_SELF’] . “?page=shop.browse&category_id=$category_id”);
$link .= “\”>”;
$link .= $db->f(”category_name”);
$link .= ““;
$category_list[$i++] = $link;
}
while (list(, $value) = each($category_list)) {
$html .= $value;
}
return $html;
}
and replace with:
function get_navigation_list($category_id, $pd = 0) {
global $sess, $mosConfig_live_site;
$db = new ps_DB;
static $i=0;
static $html = "";
$q = "SELECT category_id, category_name,category_parent_id FROM #__{vm}_category, #__{vm}_category_xref WHERE ";
$q .= "#__{vm}_category_xref.category_child_id='$category_id' ";
$q .= "AND #__{vm}_category.category_id='$category_id'";
$db->setQuery($q); $db->query();
$db->next_record();
if (($db->f("category_parent_id")) && ($i == 0) && ($pd == 0)) {
$link .= $db->f("category_name");
$category_list[$i++] = " ".$this->pathway_separator()." ". $link;
$this->get_navigation_list($db->f("category_parent_id"));
}
elseif ($db->f("category_parent_id")) {
$link = "url($_SERVER[’PHP_SELF’] . “?page=shop.browse&category_id=$category_id”);
$link .= “\”>”;
$link .= $db->f(”category_name”);
$link .= ““;
$category_list[$i++] = ” “.$this->pathway_separator().” “. $link;
$this->get_navigation_list($db->f(”category_parent_id”));
}
elseif (($i == 0) && ($pd == 0)) {
$link .= $db->f(”category_name”);
$category_list[$i++] = $link;
}
else {
$link = “url($_SERVER[’PHP_SELF’] . “?page=shop.browse&category_id=$category_id”);
$link .= “\”>”;
$link .= $db->f(”category_name”);
$link .= ““;
$category_list[$i++] = $link;
}
while (list(, $value) = each($category_list)) {
$html .= $value;
}
return $html;
}
Now after replacing the code with that there are two more files that need to be edited. Search for the next file: /administrator/components/com_virtuemart/html/shop.product_details.php
Fine the following line of code:
$navigation_pathway .= $ps_product_category->get_navigation_list($category_id);
$navigation_pathway .= " ".$ps_product_category->pathway_separator()." ". $product_name;
and replace with:
$navigation_pathway .= $ps_product_category->get_navigation_list($category_id, 1);
$navigation_pathway .= " ".$ps_product_category->pathway_separator()." ". $product_name;
And after that we have one last file to edit…almost done.
Open /includes/pathway.php
Find the following line of code:
// if it is the current page, then display a non hyperlink
if ($item->id == $Itemid || empty( $mid ) || empty($item->link)) {
$newlink = " $itemname";
and replace with:
// if it is the current page, then display a non hyperlink
if (($item->id == $Itemid && !$mainframe->getCustomPathWay()) || empty( $mid ) || empty($item->link)) {
$newlink = " $itemname";
Now you have edited 3 different files. Make sure you save your files as well that you also backed up your files. Now upload these to the server over top of the original files and you will now have working pathways for your shop.
Update:
And lastly open up all the templates located in /administrator/components/com_virtuemart/html/templates and delete the following code from all of your templates: {navigation_pathway} and this will conclude your pathway issues to make them just like ours.
Enjoy!
Developer Center