ALite CMS 44.3
Language: 
ALite CMS

Articles

Specifics of link and path usage in ALite CMS

04.04.2009 13:16  rating: 1146 

Usage of interactive page builder and SEF URLs in ALite CMS entails some specifics in construction of internal links and paths to files in scripts and editable blocks. The page builder is an independent tool, all its' files are located in the separate folder, so the user should follow some rules on how to make links and paths always show the same place.

Internal Links

To make an internal reference function correctly, it is recommended to always use a relative addressing both at the site and in the constructor. It's preferred to use the following syntax:
< a href="?param1=1 & param2=2" >text link< /a >
Such syntax is featured with a jump through the link, which path is specified relative to the current page. It is not prohibited to use absolute paths in links, but clicking such link the user quits the page constructor and jumps by the given address without page layout saving.

Examples:

1. Link address: ?rid=44
The link leads to:
site - /mydomain/?rid=44
page builder - /mydomain/_page_builder/?rid=44 (the user stays in the page builder)

2. Link address: /?rid=44
The link leads to:
site - /mydomain/?rid=44
page builder - /mydomain/?rid=44 (the user quits the page builder)


Do not use links with identification of relative address with usage of the syntax ../ !!! Such links lead to different directories at the site and in the page builder! Though it may not cause an error, but the scripts' work would be incorrect.

Examples:

1. Link address: ../?rid=44 or ../index.php?rid=44
The link leads to:
site - to the parent catalog relative to /mydomain/script_catalog/
page builder - to the parent catalog relative to /mydomain/_page_builder/script_catalog/


A syntax of link to jump to the main page also has a special feature. To make such link work correctly both at the site and in the page builder, it's recommended to use the syntax href="?", but not href="/".

Paths to files

In contrast to internal links, the user should specify an absolute path for files and other objects. Only in such way, the paths will be correct both at the site and in the page builder. It's recommended to use the following syntax:
< img src="/_uimages/banner.gif" / >

Examples:

1. < img src="/_uimages/banner.gif" / >
2. < img src="http://mydomain/_uimages/banner.gif" / >
3. < img src="< ? php echo $_SERVER['DOCUMENT_ROOT']; ? >/_uimages/banner.gif" / >
4. < script language="JavaScript" type="text/javascript" src="/_js/jquery.js" >< /script >
5. < link rel="stylesheet" type="text/css" href=" /_themes/theme_name/css/ustyle.css" / >


Links and SEF URLs

SEF URLs process HREF attribute of the A tags and ACTION attribute of the FORM tags. In this case, the link text should meet the following requirements:
1. Link text shouldn't be empty.
2. Link text should begin with domain name, interrogation point, slash or two points and slash.

Examples:
http://mydomain/?elm=articles&elmid=4&rid=25
http://www.mydomain/?elm=articles&elmid=4&rid=25
?elm=articles&elmid=4&rid=25
/?elm=articles&elmid=4&rid=25
../?elm=articles&elmid=4&rid=25

3. Link text shouldn't include file extension. For example: .php, .html and so on.
4. The transferred link parameters should meet a standard approved with ALite CMS (See Usage of SEF URLs in ALite CMS).

To process data transferred to browser through GET directly (for example, during execution of the php function header('Location: ...) there is a separate function of conversion alc_common_url_to_furl. The conversion should be executed before the data are transferred to browser.

Examples:
...
$href = '?'.(($rid > 0) ? 'rid='.$rid.'&' : '').'elm=articles';
if ($friendly_urls) $href = alc_common_url_to_furl($href);
//check whether SEF URLs are used or not
//performed directly in the conversion function alc_common_url_to_furl

$href = alc_common_url_to_furl($href);
header('Location: '.$href);
...
Comments:
$friendly_urls - predetermined in ALite CMS global variable
$friendly_urls == true; SEF URLs are used
$friendly_urls == false; SEF URLs are not used

RSS  RSS