MODx elements
As we know that MODx cms is growing to become a popular content management system with its capabilities to produce professional and high end websites. As many of you are not aware of MODx please read my blog on what MODx is or visit the MODx website. Among other popular CMS’s such as Joomla and Drupal, MODx is the most user friendly CMS I have used and picked up very quickly. MODx is very well designed and has a backend like all other CMS for users to create content and functionality.
In this article I will discuss some important elements of MODx and how to manage them. Below is a list of elements that MODx provides.
- Templates – Website templates
- Template Variables – AKA custom fields
- Chunks – Plain text or html code
- Snippets – Dynamic PHP code
- Plugins – Similar to snippet
MODx Templates
In MODx you can create your personal templates using HTML/CSS and put placeholders. MODx allows you to create multiple templates and categories these templates. Each page also known as resource can be assigned a template, allowing your website to have a different look per page.
MODx Template Variables
Template variables (TV) also known as custom fields in other words. A TV is used or displayed (via a Content Tag) to represent a value inside a template or a document. MODx allows you to have a virtually unlimited number and types of TVs. TVs are assigned to the Templates you installed.
TVs are template specific, meaning they can only be used in templates that they are assigned to. A TV can also be customized to display content for a specific document.
TVs Output Widgets make it easier for users to add special visual effects to their web sites in a matter of seconds. With just a few clicks you can add a Marquee or a Ticker to scroll or change content on your website, a Data Grid to display a formatted table of data from a file or a database, an always-present floating display box and more.
MODx Chunks
Chunks are simply blocks of plain text or (X) HTML mark-up that is inserted directly into your page at the location you place the chunk tags. And to display the chunk you can just put this in any of your pages {{chunkName}}. One advantage about using chunks is that you don’t have to repeat text or HTML code you just call the chunk tag. Chunk cannot contain PHP code; however it can contain TVs or snippet which contains PHP code.
MODx Snippets
MODx snippets are the method, which allows you to run dynamic PHP code in your pages. MODx have some pre defined function calls that you can use to query the database, make arrays, get document etc. For more information about these functions click here. One advantage about this is that if you are not familiar with MODx database API you can just use normal PHP and it would work fine.
To call a snippet in MODx you simply call this [[snippetName]] in any of your document where you want the PHP code to run.
MODx Plugin
MODx Plugins are parallel to snippets in that they are snippets of code that have access to the MODx API – however the big distinction is that plugins are related to specific system events. For example, in an average MODx page request, several events happen at certain points within the page parsing process and plugins can be attached to any of these events to fulfil a desired function. Plugins aren’t just limited to front-end processing though; there are many events that are available in the MODx Manager.



