Random Image

Configurable Menu Order

Decoders and Modules
W3 Validator

Valid XHTML 1.0 StrictValid CSS!

Decoders and Modules

In this page, we discuss the way to extend CCMS with the help of providing new decoders and modules. Besides reading this page, you may want to observe the folders. CCMS comes with a few prebuilt modules.

Decoders

Decoders are placed in /decoder folder with function name of ccms_decoder_DecoderName. Also, global array variable $ccms_decoders should contain such an entry. For example, decoder gallery has filename of /decoder/gallery.php with function name of ccms_decoder_gallery, also "gallery" inside $ccms_decoders.

When a path is given by user from the URL, CCMS checks if there are any files with extension the same as a decoder. For example, Rebecca.gallery will be decoded as a gallery and "About_me.html" will be decoded as a html document.

Note that there is at most one decoder call per page request. When no suitable decoder is found, CCMS continues to see if the MIME of the file extension (global map variable $ccms_mime) is defined. If yes, the file will be downloaded plainly. Otherwise access denied will be given. This is a feature to protect against accessing some sensitive-content files.

Decoder is given one parameter when it is executed - file. Besides, there are a few global variables to access in order to finish decoding process. Indeed, decoder function does not need to return anything. These processes include

Aim Action
Provide decoded content for the page Change $ccms_content
Change title of a page Change $ccms_title.
Switch off template and output raw file Change $ccms_template to false.
Switch off a module Make use of array_diff() and the four module lists.(See Gallery module source)

Modules

Modules are placed in /module folder with function name of ccms_module_ModuleName. For example, module navigation has filename of /module/navigation.php with function name of ccms_module_navigation.

Location of modules can be configured by placing module names into one or more of the global array variables $ccms_left_modules, $ccms_right_modules, $ccms_top_modules and $ccms_bottom_modules. These variables can be modified on the fly while decoder is running.

Modules are given one parameter when it is executed - file. Similar to decoders, modules can access the global variables. Please see the table in Decoders section for insights. Modifying them is however less recommended as a few modules may interfere each others if they change these parameters altogether.

Modules are expected to return a value to notify caller result of execution. There are three modes of return values for different situations.

Situation Return Value
Hide the module Return false or do not return at all.
Show module without title Return formatted HTML string.
Show module with title Return map of title and content to corresponding formatted HTML string.

Powered by Charray's CMS.