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

How Do I remove "/component/virtuemart/" or rename in the URLS??

Started by malibu2792, April 11, 2012, 22:06:23 PM

Previous topic - Next topic

malibu2792

I am wanting to make my url's as SEF as possible. I would like to reword the "/component/virtuemart/" in the URLs. How do I do this?

SEF is enabled.

Joomla! 2.5.4
Virtuemart 2.0.4

patrik60

Did you also enable SEF in VM configuration (last tab in VM config)?

jjk

Quote from: malibu2792 on April 11, 2012, 22:06:23 PM
... reword the "/component/virtuemart/" in the URLs. How do I do this?

Is your site multilingual?
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

SamF

Quote from: malibu2792 on April 11, 2012, 22:06:23 PM
I would like to reword the "/component/virtuemart/" in the URLs. How do I do this?

Easy enough. Assign Virtuemart Front Page to any menu item.

PRO

Quote from: malibu2792 on April 11, 2012, 22:06:23 PM
I am wanting to make my url's as SEF as possible. I would like to reword the "/component/virtuemart/" in the URLs. How do I do this?

SEF is enabled.

Joomla! 2.5.4
Virtuemart 2.0.4


For best urls

Create 1 menu to vmart frontpage layout


THEN, create menu links to the categories

patrik60

QuoteCreate 1 menu to vmart frontpage layout

I always read this here in the forum. I don't understand what it means. A menu can't be assigned to a layout. You can assign menu links to layouts, categories, articles etc. So what does it really mean? It's a difference between creating menus or menulinks, isn't it?

PRO

Quote from: patbe60 on April 12, 2012, 21:56:02 PM
QuoteCreate 1 menu to vmart frontpage layout

I always read this here in the forum. I don't understand what it means. A menu can't be assigned to a layout. You can assign menu links to layouts, categories, articles etc. So what does it really mean? It's a difference between creating menus or menulinks, isn't it?

Please see image



[attachment cleanup by admin]

patrik60

Thank you, I know about this magic. But this is not "creating a menu". For sure every Joomla and VM user is creating menu links in order to see his shop in the frontend. So I thought you mean something special. Or isn't it the same to create a menu link to the frontpage layout of VM as creating menu links to VM categories?  ???

SamF

Quote from: patbe60 on April 12, 2012, 22:15:55 PM
to see his shop in the frontend.

The VM frontpage becomes the site frontpage only if you set certain menu item as "default".

Create the new menu for VM, set the menu item for VM frontpage, and do not create the front page module for this menu: you will not see your shop in the frontend (if you don't want to:).  Even more, you will not see VM in visible links on your page.

But you will get beautiful SEF links to VM pages.

dmbart

Quote from: BanquetTables.pro on April 12, 2012, 20:17:29 PM
Quote from: malibu2792 on April 11, 2012, 22:06:23 PM
I am wanting to make my url's as SEF as possible. I would like to reword the "/component/virtuemart/" in the URLs. How do I do this?

SEF is enabled.

Joomla! 2.5.4
Virtuemart 2.0.4


For best urls

Create 1 menu to vmart frontpage layout


THEN, create menu links to the categories

Thanks this did it for me.

lipes

If we use VM product module (random, featured, etc..) in frontend Index.php with SEF -> ON ... we will see the "/component/virtuemart/" when someone click in the product  of that module.. it's bad ...
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

PRO

lipes, I do not get that.
Because I have menu links to every top level category

lipes

Sorry BTPro!  I didnt remember that i've changed the router.php some months ago, because i need that to work with the product category filter module.

I also got menu links for every categories in Joomla 'Menu' > 'Mainmenu' Menu Item Type links ( VirtueMart » Category Layout ) and others to ( VirtueMart » VirtueMart Categories Layout ) @ ( /administrator/index.php?option=com_menus&view=items&menutype=mainmenu )

If visitor goes by Main Menu works perfect! Like you said :) For example: "Image and Sound" > "HiFi" the visitor will see: http://localhost/template/image-and-sound/hifi

The problem it's in Router.php ... if the visitor clicks in any product will see this kind of link: http://localhost/template/component/virtuemart/?view=productdetails&virtuemart_product_id=729&virtuemart_category_id=15
So i've decided to dont use vm products module because i get this problem

BtW here's my actual (not perfect) router.php file
<?php

function VirtuemartBuildRoute(&$query) {
  
$db =& JFactory::getDBO();
$segments = array();
  
$category_id = (isset($query['category_id']))? $query['category_id'] : '';
  
$product_id = (isset($query['product_id']))? $query['product_id'] : '';
  
$manufacturer_id = (isset($query['manufacturer_id']))? $query['manufacturer_id'] : '';
  
  
// category
  
if (isset($query['page']) && $category_id) {
    if (
$query['page'] == 'shop.browse') {

      
//lookup category name set as segment
      
$sql "SELECT category_name FROM #__vm_category WHERE category_id = " $category_id;
      
$db->setQuery($sql);
      
$category_name $db->loadResult();
      if (
strlen($category_name)) {
        
$category_name strtolower($category_name);
        
$category_name str_replace(' ''-'$category_name);
        
$category_name str_replace('/''-'$category_name);
        
$entities = array('%21''%2A''%27''%28''%29''%3B''%3A''%40''%26''%3D''%2B''%24''%2C''%2F''%3F''%25''%23''%5B''%5D');
        
$category_name str_replace($entities''urlencode($category_name));
        
$segments[] = $category_name;
      }

      unset(
$query['page']);
      unset(
$query['category_id']);
    }
  }
  
  
// manufacturer
  
if (isset($query['page']) && $manufacturer_id) {
    if (
$query['page'] == 'shop.browse') {

      
//lookup category name set as segment
      
$sql "SELECT mf_name FROM #__vm_manufacturer WHERE manufacturer_id = " $manufacturer_id;
      
$db->setQuery($sql);
      
$manufacturer_name $db->loadResult();
      if (
strlen($manufacturer_name)) {
        
$manufacturer_name strtolower($manufacturer_name);
        
$manufacturer_name str_replace(' ''-'$manufacturer_name);
        
$manufacturer_name str_replace('/''-'$manufacturer_name);
        
$entities = array('%21''%2A''%27''%28''%29''%3B''%3A''%40''%26''%3D''%2B''%24''%2C''%2F''%3F''%25''%23''%5B''%5D');
        
$manufacturer_name str_replace($entities''urlencode($manufacturer_name));
        
$segments[] = $manufacturer_name;
      }

      unset(
$query['page']);
      unset(
$query['manufacturer_id']);
    }
  }

  
// product details
  
if (isset($query['page']) && $product_id) {
    if (
$query['page'] == 'shop.product_details') {
    
      
//prevent duplicate urls by chosing the category id with the highest list order
      
$sql "SELECT #__vm_category.category_id
              FROM #__vm_product
                INNER JOIN #__vm_product_category_xref 
                  ON (#__vm_product.product_id = #__vm_product_category_xref.product_id)
                INNER JOIN #__vm_category 
                  ON (#__vm_category.category_id = #__vm_product_category_xref.category_id)
              WHERE (#__vm_product.product_id = " 
$product_id "
                AND #__vm_category.category_publish = 'Y')
              ORDER BY #__vm_category.list_order ASC
              LIMIT 0,1"
;
      
$db->setQuery($sql);
      
$category_id $db->loadResult();

      
//lookup category name set as url segment
      
$sql "SELECT category_name
                FROM #__vm_category
                WHERE category_id = " 
$category_id;
      
$db->setQuery($sql);
      
$category_name $db->loadResult();
      if (
strlen($category_name)) {
        
$category_name strtolower($category_name);
        
$category_name str_replace(' ''-'$category_name);
        
$segments[] = $category_name;
      }

      
//lookup product name and set as url segment
      
$sql "SELECT product_name FROM #__vm_product WHERE product_id = " $product_id;
      
$db->setQuery($sql);
      
$product_name $db->loadResult();
      if (
strlen($product_name)) {
        
$product_name strtolower($product_name);
        
$product_name str_replace(' ''-'$product_name);
        
$product_name str_replace('/''-'$product_name);
        
$entities = array('%21''%2A''%27''%28''%29''%3B''%3A''%40''%26''%3D''%2B''%24''%2C''%2F''%3F''%25''%23''%5B''%5D');
        
$product_name str_replace($entities''urlencode($product_name));        
        
$segments[] = $product_name;
      }

      if (isset(
$query['flypage'])) unset($query['flypage']);
      unset(
$query['page']);
      unset(
$query['product_id']);
      unset(
$query['category_id']);
      unset(
$query['manufacturer_id']);

    }
  }
  
  
// unique id
  
$unique_id = (strlen($category_id)) ? $category_id '';
  
$unique_id .= (strlen($product_id)) ? "-" $product_id '';
  if (
strlen($manufacturer_id && !strlen($unique_id))) {
    
$unique_id "m" $manufacturer_id;
  } 


  
$segments[] = $unique_id;

  unset(
$query['option']);
$query['option'] = 'com_virtuemart';
return $segments;
}

function 
VirtueMartParseRoute($segments) {
  
  
$vars = array();
  
$segment_count count($segments);
  
$category_id '';
  
$product_id '';
  
  
// categories
  
if ($segment_count == 2) {
    if (
strstr($segments[1], "m")) { // manufacturer
      
$vars['manufacturer_id'] = str_replace('m'''$segments[1]);
    } else { 
// category
      
$vars['category_id'] = $segments[1];
    }
    
$vars['page'] = 'shop.browse';
  }

  
// product details
  
if ($segment_count == 3) {
    
$vars['page'] = 'shop.product_details';
    list(
$category_id$product_id) = explode(":"$segments[2]);
    
$vars['product_id'] = $product_id;
  }

  return 
$vars;
}


?>

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

PRO


lipes

yet in the 2.0.18b but  that router.php file it's an old file that as been used to filter work with SEF...
i've did once again the search and now remember where i've found... the file was taken from this website: http://paulmason.name/item/search-engine-friendly-sef-urls-for-virtuemart
(in fact it's an old post, but it's working until now... only miss the correct name call of the VM frontend Modules..)

If i use the actual version of router.php the product filter doesnt work with SEF "On" but works with SEF off ..
maybe this file could solve some forum members problems

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