X-Cart:Rules for Defining Hyperlinks

From X-Cart 4 Classic
Jump to: navigation, search

On the pages of your store, you can provide hyperlinks to other resources on the Web. You can define hyperlinks using two types of paths: absolute and relative. Links to documents on other websites must be defined using absolute paths; for example, http://www.google.com/index.html. Links to documents on the same site with your store can be either absolute or relative, whatever is more convenient to you.

Example 1.

If your store's URL is http://example.com, and you wish to create a link from the page http://example.com/home.php to the script script.php located in the directory sample_dir (http://example.com/sample_dir), you should use one of the following paths:

Example 2.

If your store's URL is http://example.com/shop, and you wish to create a link from the page http://example.com/shop/home.php to the script script.php located in the directory sample_dir (http://example.com/shop/sample_dir), you should use one of the following paths:

  • /shop/sample_dir/script.php (an absolute path without the domain name);
  • sample_dir/script.php (a relative path).

If you are planning to use X-Cart's HTML catalog feature, please be aware of the following: During the generation of an HTML catalog, X-Cart converts all the paths used in hyperlinks into full URLs. At present, the method of conversion provided by X-Cart works for all types of paths; however, the conversion of relative paths with the leading ./ or ../ (like "./script.php" or "../script.php") results in really ugly full URLs: the resulting full URLs are inefficiently long and non user friendly. Until we provide a better method for converting such paths, we recommend that you avoid using paths with the ./ and ../ indications.

Please note that the 404 error page shipped with X-Cart distribution package uses the <base> tag. When editing the file 404_US.html, you can find this tag in the head of the document. This tag defines the path to your store's root. Because the 404 error page uses this tag, all the hyperlinks in it are based on relative paths. If you decide to edit the hyperlinks included into your store's 404 error page, remember that you must create them using relative paths - as long as you keep the <base> tag. If you decide to remove the <base> tag from the source code of the 404 error page, any hyperlinks will have to be based on absolute paths.