Chain
Chains in CONTENIDO are important to inject custom functionality into the system without changing the core files. This is important, because the system then 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 by step.
First create your Chain and save it to /contenido/includes/chains/:
<?php defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.'); function cecFrontendCategoryBusinessAccess($name) { global $cfg; // your code stuff 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:
<?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.BusinessAccess', 'cecFrontendCategoryBusinessAccess'); //here we add our Chain to the cecRegistry
Now our Chain is ready to use.
Here an example to be used in your module code:
$_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Frontend.BusinessAccess'); if ($_cecIterator->count() > 0) { while (false !== $chainEntry = $_cecIterator->next()) { $businessName = $chainEntry->execute("Fritz Box"); } }
When does it make sense to use chains for CONTENIDO?
The use of CECs within CONTENIDO makes sense if the base functionality of CONTENIDO could be changed in a project without rewriting code of CONTENIDO itself. If the CEC is placed at the correct location, each project can access these chains.
What are the restrictions for chains?
CECs should only be used for data manipulation. They should not be used to manipulate GUIÂ elements, as the GUI stuff within CONTENIDO will be changed soon.
List of existing chains
You can't use any of these chains for your purpose?
If you can not use any of these chains listed below you can request a new and it is maybe implemented in the next version. Please visit the chain request thread in our forum.
CEC Hook | Description | Parameters | Since version |
---|---|---|---|
Contenido.Content.AfterStore | This chain is called after one or more content entries are stored. It could be used as hook for indexing articles. | Array $articleIds with keys idclient, idlang, idcat, idart, idcatlang, idartlang. | 4.9.0 |
Contenido.Content.conGenerateCode | This chain is called in function conGenerateCode after code is created. | Â | 4.9.0 |
Contenido.Content.CopyArticle | This chain is called everytime when an article is duplicated. | Integer with articleId of original article, integer with articleId of duplicated article | 4.9.0 |
Contenido.Content.CreateArticleLink | This chain is called when a frontend link to an article will be created. | Integer idart, integer idcat | 4.9.0 |
Contenido.Content.CreateCategoryLink | This chain is called when a frontend link to a category will be created. | Integer idcat | 4.9.0 |
Contenido.Content.CreateMetatags | This chain is used to build up an user defined metatag array. Adds, modifies or removes meta tags of an article | Array with all meta tags | 4.9.0 |
Contenido.Content.CreateTitletag | This chain is used to build a user defined title element. | Â | 4.9.0 |
Contenido.Content.DeleteArticle | This chain is called when article is deleted. | String idart | 4.9.0 |
Contenido.Content.IndexArticle | This chain is called search index generation. Since CONTENIDO 4.9.5 you can configure at config.misc.php configuration file ($cfg['search_index']['excluded_content_types']) all content types that you want to be excluded from indexing. | Array with all article ids ($articleIds) | 4.9.0 |
Contenido.Content.SaveContentEntry | This chain is called before a single content entry is saved. It allows to modify the given content to be saved which will then be returned by this function. | Integer $idartlang, integer $type, integer $typeid, string $value | 4.9.0 |
Contenido.Upload.UploadPreprocess | This chain is called everytime a file is uploaded. | String with temporary filename you have to use to process, string with new filename the uploaded file will be stored as | 4.9.0 |
Contenido.Upload.UploadPostprocess | This chain is called everytime after a file is uploaded and stored in its final position. | String with full path and name of the uploaded file | 4.9.0 |
Contenido.ArticleCollector.Articles | This chain is called when article collector loads articles. | Array $data, an associative array with idart of current article and loaded articles | 4.9.5 |
Contenido.Frontend.CategoryAccess | This chain is called everytime the user tries to access a protected category. | Integer languageId, integer idcat, string userId | 4.9.0 |
Contenido.ArticleCategoryList.ListItems | This chain is called when the category list in Content -> Articles will be build. | Â | Â |
Contenido.ArticleList.Columns | This chain is used to process the columns of the article list. | Array in the format $key => $description | Â |
Contenido.ArticleList.Actions | This chain is used to process the actions for articles. | Array in the format $key => $description | Â |
Contenido.ArticleList.RenderColumn | This chain is used to render a single column for a specific article. | Integer idcat, integer idart, integer idartlang, string with column key to render | Â |
Contenido.ArticleList.RenderAction | This chain is used to render a single action for a specific article. | Integer idcat, integer idart, integer idartlang, string with action key to render | Â |
Contenido.CategoryList.Columns | This chain is used to process the columns of the category list. | Array in the format $key => $description | Â |
Contenido.CategoryList.RenderColumn | This chain is used to render a single column for a specific category. | Integer idcat, string with column key to render | Â |
Contenido.Frontend.AllowEdit | This chain is used when an article is about to be edited. It can be used to prevent users to edit certain articles, e.g. for workflows or for special types of articles. | Integer with languageId, integer idcat, integer idart, string with authentification of the user | 4.9.0 |
Contenido.Permissions.User.Areas | This chain returns all areas which will appear in the user rights management. |  |  |
Contenido.Permissions.User.GetAreaName | This chain returns the localized area name for a technical area name. | String with technical area name | Â |
Contenido.Permissions.User.GetAreaEditFilename | This chain returns the filename required for the permission editor. | String with technical area name | Â |
Contenido.Permissions.FrontendUser.AfterDeletion | This chain function is called after a frontend user has been deleted from the database. | Integer with id of deleted frontend user | Â |
Contenido.Permissions.FrontendUser.BeforeStore | This chain function is called before storing a frontend user. It allows for easier data manipulation for extended frontend users with interdependend attributes. | Array | Â |
Contenido.Permissions.Group.Areas | This chain returns all areas which will appear in the group rights management. | Array with all unique technical area names which should appear in the group rights management |  |
Contenido.Permissions.Group.GetAreaName | This chain returns the localized area name for a technical area name. | String with technical area name | Â |
Contenido.Permissions.Group.GetAreaEditFilename | This chain returns the filename required for the permission editor. | String with technical area name | Â |
Contenido.Article.RegisterCustomTab | This chain registers a custom tab into the main article subnavigation (Overview/Properties/Configuration/Editor/Preview/***). | Â | Â |
Contenido.Article.GetCustomTabProperties | This chain is called when the properties of a custom tabs need to be aquired. It is used to build the final URL for the editor. | String with technical area name | Â |
Contenido.Frontend.BaseHrefGeneration | This chain is called everytime the BASE HREF tag is generated. | BASE HREF URL from CONTENIDO configuration array | 4.9.0 |
Contenido.Upl_edit.Delete | This chain function is called after each single upload file has been deleted. | int $idupl, string $dirname, string $filename | Â |
Contenido.Upl_edit.DeleteBatch | This chain function is called after one or more upload files have been deleted. | array:cApiUpload $uploads |  |
Contenido.Upl_edit.Rows | This chain is used to process the rows of the upl-details list. | Array with row-list for upl-details | Â |
Contenido.Upl_edit.RenderRows | This chain is used to render a single column for a specific article. | Integer with uploaded fileId, string with file directory, string with filename, string with row-key to render | Â |
Contenido.Upl_edit.SaveRows | This chain is called everytime when upl-details is saved. | Integer with uploaded fileId, string with file directory, string with filename | Â |
Contenido.Action.str_newtree.AfterCall | This chain is called while executing code for action "str_newtree", see table con_action. | Assoziative array with several values | 4.9.0 |
Contenido.Action.str_newcat.AfterCall | This chain is called while executing code for action "str_newcat", see table con_action. | Assoziative array with several values | 4.9.0 |
Contenido.Action.str_renamecat.AfterCall | This chain is called while executing code for action "str_renamecat", see table con_action. | Assoziative array with several values | 4.9.0 |
Contenido.Action.str_moveupcat.AfterCall | This chain is called while executing code for action "str_moveupcat", see table con_action. | Integer idcat | 4.9.0 |
Contenido.Action.str_movedowncat.AfterCall | This chain is called while executing code for action "str_movedowncat", see table con_action. | Integer idcat | 4.9.0 |
Contenido.Action.str_movesubtree.AfterCall | This chain is called while executing code for action str_movesubtree, see table con_action. | Assoziative array with several values | 4.9.0 |
Contenido.Action.con_saveart.AfterCall | This chain is called while executing code for action con_saveart, see table con_action. | array $newdata, array $oldata | 4.9.0 |
Contenido.Article.conMoveArticles_Loop | This chain is called while looping articles which will be moved for the time management function, see conMoveArticles(). | Assoziative array of actual recordset | 4.9.0 |
Contenido.Article.conCopyArtLang_AfterInsert | This chain is called after execution of the insert statement during duplication of an article, see conCopyArtLang(). | Assoziative array of actual recordset | 4.9.0 |
Contenido.Article.conSyncArticle_AfterInsert | This chain is called after execution of the insert statement during a article sync, see conSyncArticle(). | Assoziative array | 4.9.0 |
Contenido.Category.strSyncCategory_Loop | This chain is called while looping categories which will be synchronized, see strSyncCategory(). | Assoziative array of actual inserted con_cat_lang recordset | 4.9.0 |
Contenido.Category.strCopyCategory | This chain is called after a old category was copied to new category. | Assoziative array of several objects (oldcat, newcat, newcatlang) | 4.9.0 |
Contenido.Category.strRenameCategory | Â | Assoziative array of several objects (new/old category name and new/old category alias s) | 4.9.0 |
Contenido.Category.strRenameCategoryAlias | Â | Assoziative array of several objects (new/old category alias | 4.9.0 |
Contenido.Frontend.AfterLoadPlugins | This chain is called in front_content.php and provides a possibility to execute userdefined functions after plugins are loaded. | Â | 4.9.0 |
Contenido.Frontend.HTMLCodeOutput | This chain is called in front_content.php after the output of the page was buffered. | string $htmlCode | 4.9.0 |
Contenido.Frontend.PreprocessUrlBuilding | This chain is called by Contenido_Url->build() method an provides a way to modifiy the parameter which will be passed to the configured Url Builder. | Assoziative array of parameter beeing achieved as arguments to Contenido_Url->build() | 4.9.0 |
Contenido.Frontend.PostprocessUrlBuilding | This chain is called by Contenido_Url->build() method an provides a opportunity to modifiy a url created by configured Url Builder. | String with created url by Url Builder | 4.9.0 |
Contenido.Template.BeforeParse | This chain is called before parsing a template in cTemplate. | string $template, cTemplate $template | 4.9.3 |
Contenido.Article.conFlagOnOffline | This chain is called after articles flagged on or offline. | array $ids, idartlangs array | 4.9.11 |
Contenido.Content.CopyToVersion | This chain is called after article copied to version. | array $idart, $idlang | 4.9.11 |
Contenido.Article.DeletecontentType | This chain is called after raw data deletion in article. | array with values idcontent, idart, idlang, idartlang | 4.9.13 |
ContenidoPlugin.UrlShortener.BeforeEdit | This chain is executed if url shortener is installed and short url changed. | $shortUrlOld, $shortUrlNew | 4.9.11 |
ContenidoPlugin.UrlShortener.BeforeRemove | This chain is executed if url shortener is installed and short url before remove. | $shortUrl | 4.9.11 |
ContenidoPlugin.UrlShortener.AfterCreate | This chain is executed if url shortener is installed and short url is created. | $shortUrl | 4.9.11 |
ContenidoAction.con_meta_saveart.AfterCall | This chain is called after metadata of article are saved. | $idart, $newData, $oldData | 4.9.0 |
Contenido.Article.ConMakeCatOnline | This chain is called after category set to online. | array $data | 4.9.7 |
Contenido.Article.ConMakeStart | This chain is called after article set to online. | array $data | 4.9.7 |
Contenido.Backend.ConMetaEditFormAdditionalRows | This chain added additional rows to the article edit form. | $idart, $idlang, $idclient, $disabled | 4.9.0 |
Contenido.AjaxMain.CustomCall | This chain is called if custom ajax mode is selected. | $_REQUEST['method'] | 4.9.11 |
Contenido.Permissions.FrontendUser.BeforeStore | This chain is called before storing a frontend user. | array $varArray | 4.9.11 |
Contenido.WYSIWYG.LoadConfiguration | This chain is called after the complete configuration. | Â | 4.9.7 |
Contenido.Article.ConMakeOnline | This chain is called when article switch to online. | $idart, $lang, $online | 4.9.7 |
Contenido.Action.con_deleteart.AfterCall | This chain is called when article is deleted. | $idart | 4.9.13 |
Contenido.Backend.AfterArticleLink | This chain is called after article link generation in article properties. | Â | 4.9.13 |