Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 2 Next »

The cUri helper class allows to create frontend URIs i.e. URIs to CONTENIDO articles. Usually 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.

Create an URI

The easiest way to create a link to an arbitray article is as follows:

$url = cUri::getInstance()->build(array(
    'lang' => $lang,
    'idart' => $idart
));

If you like to create a link to the current article you can use this snippet instead:

$url = cUri::getInstance()->build(array(
    'lang' => cRegistry::getLanguageId(),
    'idart' => cRegistry::getArticleId()
));

The called build()-method expects an associative array wich has to have at least values for the keys lang & idart but any parameter can be appended.

 

  • No labels