ModxIf you missed the first post about creating A MODx Ditto Directory this post is designed to describe the same type of 3 level directory (I am referring to the MODx document tree with ‘Levels’), but is a simpler and more elegant technique than what I had first described. Rather than using Ditto and external snippets I have condensed this down to a single, nested PHx call containing 3 separate chunks, each containing a separate Ditto call. Each of those Ditto calls is unique to the level that is being navigated. You will need to have at least some familiarity with creating Ditto calls to create this directory. NOTE: If you are using PHx your Ditto calls should be cached on an uncached page.

In order to have my PHx statement expressed in the correct location I create a second, ‘Directory’ template, identical to my primary one. By doing this you can assign your Template Variables (TV) to this template. I then replace the [*content*] area with the following PHx statement:

[*id:is=`3`:then=`{{level1Directory}}`:else=`[*isfolder:is=`1`:then=`{{level2Directory}}`:else=`{{level3Page}}`*]`*]

That’s really all there is to it. The information below is a more detailed explanation of what is occurring at each level of the directory in addition to a more advanced technique that creates a cross-categorization feature.

Document Structure

  1. Level1 (Directory Overview – Displays Categories) This level uses the top document ID (my example: 3) of your Direcoryty to identify which Ditto call is to be expressed first as you were navigating down the document tree.

    In this example we are using Ditto to call down to Level2 to return variables onto this Level1 page. This will create a ‘Category Views’ page.

    [!Ditto? &startID=`[*id*]` &depth=`1` &tpl=`directoryTopTPL`  &sortDir=`asc`!]
  2. Level2 (Single Category Overview – Displays Category Members) Level2 folders are the ‘Categories’ in this technique. This level uses the isfolder:is=`1` portion of the PHx statement. Which expresses a second Ditto call if the document is a folder, but does not posses a Level1 document ID.

    In this example we are using Ditto to call down to Level3 to partially or fully return variables within the children of a particular category. On Level1 I clicked a category, now I see the members of that category. From here I click to see a Level3 page with full member data.

    [!Ditto? &startID=`[*id*]` &depth=`2` &tpl=`directoryFolderTPL`!]
  3. Level3 (Member Overview – Displays Individual Page Data) Level3 pages are the final level of the Directory, the individual pages which contain all of the specific member data. This level uses the :else= portion of the PHx statement and is expressed if neither of the first two criteria are met.

    In this example we are using the &startID=`[*id*]` statement within a Ditto call to bring in the variables assigned to this particular page. We are basically saying, ‘return the variables for the page you are viewing’.

    [!Ditto? &documents=`[*id*]` &depth=`2` &tpl=`directoryPageTPL` &summarize=`10` &paginate=`1` &paginateAlwaysShowLinks=`1`!]

The End User

As with my previous post I also use the ManagerManager snippet to hide any unused fields from the end user or to keep them from changing fields like the ‘Uses Template’. That way all that is seen are the fields that are needed (which are usually the pagetitle and then the associated TVs). By using this approach, with a little instruction, the end user is able to build new Level2 and Level3 pages on the fly. Since we are using a single template for all these pages the correct template (and TVs) are inherited from the parent as new pages are being created. From the end user’s perspective it is pretty effortless.

Cross Categorization – Advanced

One of the limitations of this approach that I have been struggling with is that this technique, until now, lacks the ability to cross-categorize. Well, thanks to Bill Wheeler’s (@swscripts) coding, we have developed a method for tackling this issue. The first step is to create a Multi-select or Checkbox TV that will return the list of Level2 containers and assign it to your template. This becomes a cross-categorization list for your Level3 directory documents. In this example I have used the Quill snippet to create this TV list, but a Ditto call in the TV will work as well.

This also requires a slight modification to the Level2 Ditto call (below). What we are wanting is to return all the documents assigned to a category, rather than just the contents of a single Level2 directory. You must now go up a level higher to return all to the Directory Level3 documents rather than just the contents of the active Level2. It also requires the exclusion of the Level2 folders and the addition of a filter to return the documents within a given category.

[!Ditto? &startID=`[[UltimateParent? &topLevel=`0`]]` &depth=`2` &tpl=`directoryFolderTPL` &hideFolders=`1` &filter=`category1,[*id*],7` !]

The second step is where I needed to pull in a little coding help to create a plugin. At this stage of the game the cross categorization works, but once a member was placed in a category the end user would still have to go in and select the same category again (because we have somewhat divorced the categorization from the structure of the document tree) from the TV created by the Quill snippet. I really didn’t think this redundancy of process was acceptable. What I needed was for the TV to inherit the document ID of the parent, thus forcing it to be placed in the category in which it actually resides.

The end result: Personnel_Checker. This plugin will return the parent document ID and then place it into the appropriate TV with the timing of ‘OnBeforeDocFormSave’.


After some communications back and forth last weekend with @swscripts and @einsteinsboi about the benefits of replacing the MODx default TinyMCE editor with CKEditor, I decided to give it a test drive.

While there is no download in the MODx extras section for an Evolution compatible version, there were some [...] Continue Reading…


I have been a little torn this week as to the topic of my post. I have been looking over a couple of snippets that are new to me, but am really wanting to tell a story about responsibility and customer service.

For the sake of keeping this a positive [...] Continue Reading…


In a previous post, Create a User Config Page in MODx, I referenced how you could create a dynamic CSS document in MODx. While on most of my development projects I haven’t found this to be a necessary step, there are a few occasions in which this capability can [...] Continue Reading…


I am always keeping an eye out for useful MODx resources to share. I recently installed the EditArea Plugin on our Pleth site and at first glance have been happy with the results.

If you are not familiar with EditArea it is:

a free javascript editor for source code. It allows [...] Continue Reading…


Second to a truly integrated calendaring option I think one of the more desired MODx features is a fully functional eCommerce solution.

While I never personally fell in love with the hosted FoxyCart, I did appreciate it’s relative simplicity and ease of implementation. This, depsite it’s additional monthly cost.

I recently [...] Continue Reading…


I was working on a site this morning and came across a little tip with the ManagerManager snippet that I thought would be worth sharing.

Whenever I set up a Template Variable (TV) I often wish that I could move the TV fields up above the content area inside the [...] Continue Reading…


In my previous post I described how I created an end User Configuration Page in MODx. I strongly suggest you look that post over before reading this one.

What I would like to describe now is how I used an email Template Variable (TV) from that configuration page and the [...] Continue Reading…


I have always wished that MODx posessed a tool to allow an end user some direct configuration control over their site. I realize that it is possible to grant users access to HTML chunks, but this is not within the comfort zone of most non-tech users. After playing around [...] Continue Reading…


I was recently developing a MODx site and had a page in which the customer wanted to display a table with staff contact information (30-40) that could be easily maintained by the end user. I decided to use the Ditto &tpl and &tplAlt to generate most of the table [...] Continue Reading…


I just took the List Apart, 2009 survey. In previous years they have returned/shared really good information from this survey:

Whether you call yourself a user experience consultant, web developer, or content strategist; whether you design customer flows, buttons, or brands; no matter what title you hold as a full- [...] Continue Reading…


I wanted to comment on an interesting post on the Kohana site that I came across this morning by yehosef. I am not extolling the virtues of Kohana by any means, in all honesty I was completely unaware of it’s existence until a few hours ago.

I frequently state that [...] Continue Reading…


After recently launching a new site I realized that my AjaxSearch wasn’t functioning quite as I had anticipated.

This site was my first attempt at using some of the additional settings available under Tools/Configuration/Friendly URLs to create fulls URL pathways in my MODx installation. The applicable settings (radio buttons) were [...] Continue Reading…


I am currently developing a MODx site and thought I’d take a break and write a little post about using the MODx Document Object which uses document specific variables to affect output evaluated against the value of a specific Document Object(s) (complete list). I thought this might be particularly [...] Continue Reading…


I have been developing a new site over the last week and thought I would share my solution to a little MODx navigation issue that has cropped up on occasion. I often fined myself frustrated when trying to explain/discern navigational issues in the forums. So, rather than diving into [...] Continue Reading…