MODx Customisations

This page documents some customisations I've made to the MODx Content Management System, mainly for mindspill.net.

Snippets | Go to top

Snippets I've created or modified.

ShowSnippetMindspillDotNet

This snippet simply outputs the contents of another snippet as HTML code. It's being used on this page to show the snippets.

ShowChunkMindspillDotNet

This snippet simply outputs the contents of chunk. It's being used on this page to show the chunks.

DropMenu - renamed DropMenuMindspillDotNet

Modified the 0.9.1 DropMenu snippet to support the following:

  1. Show all items regardless of whether they've been flagged to appear in the menu or not.
  2. Link to a weblink's URL rather than the weblink itself.
  3. Filter docs via a regular expression on their keywords.
  4. Filter docs via a regular expression on a given template variable.
  5. Assign a class to weblinks so that they can be styled differently.

See my post on the MODx forums: [snippet] DropMenu. Modified for weblinks and regexp on keywords/TV..

The new config parameters are as follows:

&showAllInMenu
[ true | false ] If true prevents docs being filtered by their 'sitemenu' flags. i.e. all appropriate docs are output regardless of whether they've been flagged to appear in the menu or not. Defaults to false.
&useWeblink
[ true | false ] If true and the doc is of type 'reference', link to the doc's weblink (it's 'content' field) rather than to the doc itself. Defaults to false.
&keywordRegexp
[ string ] A regular expression to check against the keywords. This filters out all docs other than those with a matching keyword.
&tvRegexpField
[ string ] The name of a template variable on which to apply a regular expression. The regexp is specified using the &tvRegexpString parameter.
&tvRegexpString
[ string ] A regular expression to check against the given template variable. This filters out all docs other than those with a matching TV. The TV is specified using the &tvRegexpField parameter.
&joinMethod
[ "and" | "or" ] A string that indicates whether to join the filter results using an AND (intersection) or an OR (difference). It defaults to XOR (union).
&weblinkClass
[ string ] CSS class for a weblink's anchor. Defaults to "weblink".

I've used the new functionality to build pages of links based on the value of a "keywords" template variable, for example, on the Computing Links page. I've got several folders that store related links, like computing links or media links, then add more fine-grained categorisation by using the "keywords" TV. Folders are fine for organising resources into manageable groups, but the use of TVs allows a far more flexible fine-grained grouping.

My use of a "keywords" TV allows me to have admin defined keywords (via the built in keywords system) as well as user defined keywords (via the TV).

The changes to DropMenu could easily be used to create a section/category setup, where the sections are folders and categories are defined by the value of a template variable.

Note that allowing the use of Keywords and TVs with weblinks required some changes to core code. See Core code below.

BreadCrumbs - renamed BreadCrumbsMindspillDotNet

Modified the 0.9.1 BreadCrumbs snippet to remove the spaces at either side of the seperator and allow some config settings to be altered via request parameters.

&crumbSeparator
Define what you want between the crumbs. Defaults to "ยป".
¤tAsLink
If you want the current page crumb to be a link (to itself) then make true. Defaults to false.

ListRelated - renamed ListRelatedMindspillDotNet

Modified the 0.9.1 ListRelated snippet to show link description and allow choice of pagetitle or longtitle as link text.

&showDescriptions
If true, shows the docs description next to it's link. Defaults to false.
&linkText
[ 'pagetitle' | 'longtitle' ] Choice of link text. Defaults to 'pagetitle'.

DateEditedMindspillDotNet

Output formatted page edited date.

FlexSearchForm - renamed FlexSearchFormMindspillDotNet

Modified the FlexSearchForm snippet to support the following:

  1. Access control, i.e. hide private documents if the user doesn't have permission to view them. This functionality uses code lifted from the MODx getDocumentObject method in document.parser.class.inc.php.
  2. Added better support for weblinks.

See my post on the MODx forums: [Snippet] FlexSearchForm. Modified to hide private docs and add weblink feature..

The new parameters are as follows:

&useWeblink
[ true | false ] If true and the doc is of type 'reference', link to the doc's weblink (it's 'content' field) rather than to the doc itself. Defaults to false.
&weblinkClass
[ string ] CSS class for a weblink's anchor. Defaults to "weblink".

Note that the code I modified was that of MadeMyDay's (posted on the MODx forums at http://modxcms.com/forums/index.php/topic,2762.0.html) which added support for showing an extract of the context with highlighted search terms. The display of content extracts makes it particularly important to prevent private documents being listed to those without permission to view them.

Chunks | Go to top

Some chunks I've created or modified.

WebLoginSideBar - renamed WebLoginSideBarMindspillDotNet

Modified the 0.9.1 WebLoginSideBar to be accessible (and dropped the table-based layout). You'll also notice that the form actions are prefixed with https:[(site_name)] - remove this unless you want to login via https.

Core code | Go to top

I've modified some 0.9.1 core code, mainly to support functionality introduced by the snippets listed above.

Allow weblinks to have META Keywords and template variables

I modified /manager/actions/dynamic/mutate_content.dynamic.action.php to allow weblinks to have META Keywords and template variables. The changes were made to allow me to categorise and group weblinks with the aid of my modified DropMenu snippet, which can filter docs by a regexp on their keywords or a TV.

See my post on the MODx forums: Modifications to allow weblinks to have META Keywords and template variables.

The changes were small:

a) Modified to show the META Keywords tab for weblinks. This modification simply removed a condition that was preventing the tab being shown, namely ($content['type']=="reference" || $_REQUEST['a']==72). Since a weblink is essentially just a normal document, all other existing functionality works fine. This change was originally made to allow me to set keywords for my weblinks so that they could be grouped by keyword using the DropMenuMindspillDotNet keyword enhancement, but the TV regexp enhancement provided a more flexible approach.

b) Modified to show template variables for weblinks. This modification added the same condition mentioned above to the check which determined whether the TVs were output or not.

c) Modified to allow weblinks to have a template. This modification removed the 'template' hidden input that set the template to 0 for weblinks. The weblink needs a template associated with it so that it's template variables can be set and retrieved.

MODx forum posts | Go to top

Some posts I've submitted to the MODx forums.

Last modified: 30/05/2006 (most likely earlier as a site migration in 2006 reset some dates) Tags: (none)

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top