Versions Compared

Key

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

...

Chains in CONTENIDO are important to inject custom functionality into the system without changing the core files. This is important, because the system then is will be easier to update.

...

Adding chains

Standard CONTENIDO chains are located at directory contenido/includes/chains. To add your own chains you have to include and initializing them at configuration files at your environment config directory. We go trough it Step step by Stepstep.

First create your Chain and save it to /contenido/includes/chains/:

Code Block
languagephp
titleFile: include.chain.frontend.cat_businessaccess.php
<?php

defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');

function cecFrontendCategoryBusinessAccess($name)
{
    global $cfg;
    // your code Stuffstuff goes here
	$data =  "Your Name is:".$name;
    return $data;
}
?>

Next we load the chain. Go to your config-folder (normaly at data/production). At config.chains.load.php you define all chains available in the system. For example, we add a new chain-Function with name cecFrontendCategoryBusinessAccess:

Code Block
languagephp
titleFile: config.chains.load.php
<?php

defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');

cInclude('includes', 'chains/include.chain.frontend.cat_backendaccess.php');
cInclude('includes', 'chains/include.chain.frontend.cat_access.php');
cInclude('includes', 'chains/include.chain.content.createmetatags.php');
cInclude('includes', 'chains/include.chain.frontend.createbasehref.php');
cInclude('includes', 'chains/include.chain.content.indexarticle.php');
cInclude('includes', 'chains/include.chain.template.parsetemplate.php');
cInclude('includes', 'chains/include.chain.frontend.cat_businessaccess.php');   //here we include our new Chainfile


// get cec registry instance
$_cecRegistry = cApiCecRegistry::getInstance();
$_cecRegistry->addChainFunction('Contenido.Frontend.CategoryAccess', 'cecFrontendCategoryAccess');
$_cecRegistry->addChainFunction('Contenido.Frontend.CategoryAccess', 'cecFrontendCategoryAccess_Backend');
$_cecRegistry->addChainFunction('Contenido.Content.CreateMetatags', 'cecCreateMetatags');
$_cecRegistry->addChainFunction('Contenido.Frontend.BaseHrefGeneration', 'cecCreateBaseHref');
$_cecRegistry->addChainFunction('Contenido.Content.AfterStore', 'cecIndexArticle');
$_cecRegistry->addChainFunction('Contenido.Template.BeforeParse', 'cecParseTemplate');
$_cecRegistry->addChainFunction('Contenido.Frontend.CategoryAccessBusinessAccess', 'cecFrontendCategoryBusinessAccess');    //here we add our Chain to the cecRegistry

...

Here an example to be used it in your module code:

Code Block
languagephp
$_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Frontend.BusinessAccess');

if ($_cecIterator->count() > 0) {
    while (false !== $chainEntry = $_cecIterator->next()) {
        $businessName = $chainEntry->execute("Fritz Box");
    }
}

...

Note
titleYou can't use any of this chain these chains for your purpose?

If you can not use any of the these chains listed below you can request a new and it is maybe implemented into in the next version. Please visit the chain request thread in our forum.

...