...
Code Block | ||||
---|---|---|---|---|
| ||||
$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.
Builder | URI example | |
---|---|---|
cUriBuilderFrontcontent | front_content.php?idart=$idart&lang=$lang | |
cUriBuilderCustom | index-a-1.html | |
cUriBuilderCustomPath | category-alias/index-a-1.html | |
cUriBuilderMR | category-alias/article-alias.html | requires 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 | ||||
---|---|---|---|---|
| ||||
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 | ||||||
---|---|---|---|---|---|---|
| ||||||
$myCfg['name'] = 'front_content';
$myCfg['config'] = array();
cUriBuilderConfig::setConfig($myCfg); |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$myCfg['name'] = 'custom_path';
$myCfg['config'] = array(
'prefix' => 'rocknroll',
'suffix' => '.4fb',
'separator' => ','
);
cUriBuilderConfig::setConfig($myCfg); |