...
The cUri class allows to create and parse frontend URIs i.e. URIs to CONTENIDO articles and categories. Usually By default these URIs look like front_content.php?lang=<lang>&idart=<idart>
. The cUri allows for totally different URIs e.g. SEO-URIs that contain names of categories and articles instead of the strange looking URI mentioned above. In order to create these URIs independant of the chosen strategy for URI creation it is a good idea to use the cUri class whose functionality will be explained in this article.
...
Code Block | ||||
---|---|---|---|---|
| ||||
$param['idart'] = array( $idart; $param['lang'] => $lang, 'idart' => $idart ); $url = cUri::getInstance()->build($param); |
The called build()-method expects an associative array wich has to have at least a value for the key 'lang' but any parameter can be appended. If another builder than cUriBuilderFrontcontent is used (see below) further keys may be required.
$url = cUri::getInstance()->build("front_content.php?idart=$idart&lang=$lang");
URI to current article
If you like to create a link to the current article you can use this snippet instead which gets the values for the current language and article from the registry:
...
Code Block | ||||
---|---|---|---|---|
| ||||
$components = cUri::getInstance()->parse($url); |
cUriBuilderFactory & cUriBuilder
cUriBuilderCustom
cUriBuilderCustomPath
cUriBuilderFrontcontent
cUriBuilderMR
cUriBuilderConfig