Selecting Resources to Summarize on Your Home Page

Say you’re not particularly tech-savvy client wants to select Resources manually to promote on the Home page with a teaser. You could create a Custom Manager Page (CMP) that lets the client select (and de-select) the pages, but writing a CMP is a fairly challenging process.

You could write code that adds options to the right-click menu in the Resource Tree to add and remove resources from the list, but that’s even more challenging than creating a CMP.

You could create a form in the front end for the selection, but if you have a lot of Resources, you’d have a monster drop-down list or a lot of checkboxes.

You could also create a Template Variable and a custom snippet to check the TV, but that would make for fairly slow page loads because the snippet would have to check the TVs for all pages on the site. Worse yet, the client would have to edit each Resource to select or de-select it.

The getResources snippet will display teasers for you, and its &resources property will let you specify a comma-separated list that determines which ones will be shown. We just need a way to make it easy for the client to create that list. The client could just edit the snippet tag, but some clients don’t like to mess with anything that they consider “code,” which often includes snippet tags. Worse yet, the snippet tag will be most efficient if it’s in the Template — buried in a lot of other scary code. In addition, if they mess up the tag in any way, the page can look truly terrible or the teaser display will disappears altogether (and they’ll think they’ve broken the site).

Here’s a very low-tech (but very efficient) way to let the client select specific Resources to promote on the Home page (or any page) without seeing anything scary.

Create a chunk called HomePageResources. In it, put nothing but a comma-separated list of IDs that get shown on the Home page (no spaces).

Put a getResources tag on the Home Page where you want the teasers to appear, with this property:

[code language=”php”]

Create another chunk with tags to serve as the Tpl chunk for getResources (let’s call it TeaserTpl) and specify it in the &tpl property of the getResources tag on the Home page.

[code language=”php”]

the TeaserTpl chunk might look Something like this:

[code language=”php”]
<div class="resource_preview">

Now, all the client has to do to update the display is to look in the Resource tree and note the IDs of resources to be shown and type them into the chunk (and remove the ones that should no longer be shown). If the client knows the pagetitle (or part of it) for a Resource they want to add or remove, they can use the Search box at the top of the Resource tree to find the ID.

To improve page-load speeds, you’ll want to call the getResources snippet cached (as it appears above). That means you’ll have to remind the client to clear the site cache from the Manager’s Top Menu whenever the list changes.

The tag specifying the value of the &resources property in the getResources snippet tag will be replaced with the comma-separated list in the chunk and Bob’s your uncle. The client never has to deal with (or even see) the snippet tag.

For more information on how to use MODX to create a web site, see my web site Bob’s Guides, or better yet, buy my book: MODX: The Official Guide.

Looking for quality MODX Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , | Posted under MODX, MODX | RSS 2.0

Author Spotlight

Bob Ray

Bob Ray is the author of MODX: The Official Guide and over 30 MODX add-on components. He hosts Bob's Guides, a source of valuable information for MODX users, and has been very active in the MODX Forums with over 19,000 posts.

Leave a Reply

Your email address will not be published. Required fields are marked *