Since this tip might come in handy for many others out there, I decided to write this little tutorial in English. Since I am not a native speaker, I apologize for my poor language. If you have any questions to this tutorial, feel free to add a comment. I’ll reply back!

So you are using VirtueMart on Joomla and you are using the SEF-extension sh404SEF? It is said to be the best SEF-Tool for VirtueMart. I can’t judge that, since I haven’t tried other plugins for this use-case. But this plugin is to some extend a little tricky. Especially, as I found out, when you are using the virtuemart-category-IDs on URLs.

The problem

First of all: What is this all about?

Basically, the SEF-Tool switches nasty url-strings like index.php?option=com_virtuemart&Itemid=7&category_id=205&flypage=flypage.tpl&lang=de&page=shop.product_details&product_id=3024 to nicer ones, which read like: my_shop_category/product_sku/product_name.html Search engines like that kind of URLs better that those unreadable gibberish strings.

If you are using sub-categories on virtuemart, you might think about adding the IDs to the URLs. You would do that, if you had sub-categories with identical name under different parent-categories. Sub-cCategory-URLs including their IDs help search engines to know, that those are different. But: sh404SEF has the little bug (or is it a feature?), that if you activate using IDs in category-URLs, it also adds them to the page title, which is not that useful.

To deactivate the category-IDs from the page title, you’ll have to hack a PHP-File. It sounds hardy, but it isn’t.

Remove the category ID from the page title

  1. Use your familiar FTP-application, connect to your VirtueMart store and go to the folder /components/com_sh404sef/meta_ext
  2. Here you will find a file called “com_virtuemart.php“. Open that file in an editor.
  3. Look for the first function that is declared in this file. It begins with function vm_sef_get_category_title( &$db, &$catDesc, $category_id, $option, $shLangName ){
  4. Later on in this function, around line 81, you’ll find this declaration of the page title:
    $title='';
    do { // all categories and subcategories
    $title .= ( $sefConfig->shInsertCategoryId ?
    $tree[ $category_id ]->category_id.$sefConfig->replacement : '')
    .$tree[ $category_id ]->category_name. ' | ';
    $category_id = $tree [ $category_id ]->category_parent_id;
    } while( $category_id != 0 );
    return rtrim( $title, ' | ');
  5. You will have to change the first set of definition to the page title. Change the lines
    $title .= ( $sefConfig->shInsertCategoryId ?
    $tree[ $category_id ]->category_id.$sefConfig->replacement : '')
    .$tree[ $category_id ]->category_name. ' | ';
    to
    $title .= /* ( $sefConfig->shInsertCategoryId ?
    .$tree[ $category_id ]->category_id.$sefConfig->replacement : '') */
    $tree[ $category_id ]->category_name. ' | ';
    That means that you comment out (“/* comment here */”) using the category id in your page title. You could also delete this, but I prefer leaving such reductions in the original PHP-file for later reference.
  6. Be sure to remove the “.” before the second $tree-variable, otherwise you shop won’t work. an return a PHP-error.
  7. Save that file and re-upload it to its destination folder.

Done! You dont’t even need to purge your SEF-URLs.

, , , , ,