Ecommerce Templates > Search engine friendly > Converting dynamic to static URLs - PHP Version

Converting dynamic to static URLs - PHP Version

search engine friendly

The default URL for a products page would be something like www.yoursite.com/products.php?cat=2 but it is possible to change this to something even more search engine friendly like www.yoursite.com/productname.php. You can also do the same for the category pages and the product detail, the information is outlined below.

Make a copy of products.php and call it say bobswidgets.php
Now, open this page in notepad or your web editor and go to HTML view. Now, you should see a set of include files like this:

<?php include "vsadmin/db_conn_open.php"?>
<?php include "vsadmin/inc/languagefile.php"?>
<?php include "vsadmin/includes.php"?>
<?php include "vsadmin/inc/incfunctions.php"?>
<?php include "vsadmin/inc/incproducts.php"?>

Now just add the variable to specify the category before the incproducts include like this for PHP

<?php include "vsadmin/db_conn_open.php"?>
<?php include "vsadmin/inc/languagefile.php"?>
<?php include "vsadmin/includes.php"?>
<?php include "vsadmin/inc/incfunctions.php"?>
<?php
$explicitid=2;
?>
<?php include "vsadmin/inc/incproducts.php"?>

You can now do the same for categories.php and proddetail.php by adding the explicitid before:

<?php include "vsadmin/inc/inccategories.php"?>

and

<?php include "vsadmin/inc/incproddetail.php"?>

As the explicit id for a product detail page is a product reference, you have to enclose this in quotes like this:
$explicitid="yourprodref";

You can get the variable you need by browsing your site and checking the particular page URL. For example if your URL for a widget looks like this:

www.yoursite.com/products.php?cat=14

...then you would want to set

<?php
$explicitid=14;
?>

You can also define the static URL in the categories admin page after following the instructions above. This is an optional feature and if you want to use it just place the name of the static page you have created.

Static categories

This now means that your menu system won't pick up on the dynamic URLs as the store is browsed. It also works with the CSS dynamic menus and avoids duplicate URLs / content on the store.

In version 4.9.6 we added linked product detail static pages where there is now an option in the product admin page "Has static page" which if checked will cause the product detail page link to take the form. . .
the_product_name.php
. . . where the page name will be made of the product name, in lower case with spaces replaced by underscores and non alphanumeric characters removed. It will be your responsibility to create the static detail page of that name using the method above.

In version 5.1 we added the ability to change the underscore to the character of you choice so if you prefer the layout of the-product-name.php then you will need to add this to includes.php

$urlfillerchar='-';

Top of page

Dynamic title and meta description tags on static pages

One of the advantages of setting up static pages is that you can add your own meta and title tags manually page by page. It is however possible to use dynamic title and meta description tags if you prefer. The method is the same as described here but with a couple of small differences. You will need to define the explicitid, catid or prodid somewhere before the metainfo include line so for the PHP version the top of the code would look something like this

<?php
session_cache_limiter('none');
session_start();
ob_start();
include "vsadmin/db_conn_open.php";
include "vsadmin/inc/languagefile.php";
include "vsadmin/includes.php";
include "vsadmin/inc/incfunctions.php";
$explicitid="prodref";
$prodid="prodref";
include "vsadmin/inc/metainfo.php";?>

If you are setting this up on a categories page, you'd want to use catid rather than prodid. For the manufacturers page that would be manid.

Top of page

More search engine friendly features from Ecommerce Templates

Top of page