Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
linenumberstrue
$builder = cUri::getInstance()->getUriBuilder();

cUriBuilderFactory

...

cUriBuilderCustom

cUriBuilderCustomPath

cUriBuilderFrontcontent

cUriBuilderMR

...

, cUriBuilder & cUriBuilderConfig

The builder defines how URIs look like and implements their creation. CONTENIDO comes with a couple of predefined builder classes but other classes can be implemented to suite your needs. As the class cUriBuilderFactory is a factory allowing to create builder instances all builder classes have to follow the common CONTENIDO naming scheme for classes and their filenames. Furthermore all builder classes should be implemented as singletons. N.b. usually there is no need to use a builder instance directly as the cUri class acts like a facade for it.

BuilderURI example 
cUriBuilderFrontcontentfront_content.php?idart=$idart&lang=$lang 
cUriBuilderCustomindex-a-1.html 
cUriBuilderCustomPathcategory-alias/index-a-1.html 
cUriBuilderMRcategory-alias/article-alias.htmlrequires AMR

HTTP base path

All builder classes hav a member to hold the URL that is used as base for an absolute path (see above), e.g. 'http://contenido.org/'. The abstract class cUriBuilder offers a getter and a setter for this member.

URL

Builders allow to build an URI using the abstract public function buildUrl(). In order to retrieve the built URI the method getUrl() has to be used.

 

Code Block
languagephp
linenumberstrue
cUriBuilderFrontcontent::getInstance()->buildUrl($param, $absolute);
$url = cUriBuilderFrontcontent::getInstance()->getUrl();

Configuration

Configure cUriBuilder URL style. Per default, configures for style index-a-1.html. If you need another style, extend this class to your needs and pass it to desired cUriBuilder. The cUriBuilderConfig::setConfig() must be called at least once to initialize the desired UriBuilder.

 

Code Block
languagephp
titleExample for default front_content cUriBuilder
linenumberstrue
$myCfg['name'] = 'front_content';
$myCfg['config'] = array();
cUriBuilderConfig::setConfig($myCfg);
Code Block
languagephp
titleExample for CustomPath cUriBuilder
linenumberstrue
$myCfg['name'] = 'custom_path';
$myCfg['config'] = array(
	'prefix' => 'rocknroll',
	'suffix' => '.4fb',
	'separator' => ','
);
cUriBuilderConfig::setConfig($myCfg);