Quote from: ppaul at Jun 25, 2006, 06:51 AM
... depending on "live-conditions". How to deal with these in MODx??
Here’s a case study from one of our sites, (as you’d say - it uses conditional logic) in this example to load a different/custom left menu navigation list depending on the title of a page. It uses the "tvcnd" snippet courtesy of Mark Caplan 26-Feb-2006.
1. We have advertisers and each have a page containing information they wish published about them and/or their business.
2. Each advertiser (we’ll call our example advertiser ’Matilda’) has the ability to add custom URLs to the bottom half of the left navigation, including, banner advertisements that they might wish to sell or give to persons interested in advertising at their page.
A. We installed Mark’s snippet "tvcnd"
B. We created a custom back end admin panel so advertisers can modify links then applied to a custom left navigation chunk, in this example we call that chunk "Matildas-Menu".
C. We created a copy of the main template, and called that "Custom-Profile"
D. In "Custom-Profile", where the site left navigation chunk is located, we replaced the chunk with this snippet call [!tvcnd? &tv=`pagetitle` &cnd=`Matilda, 2` &rtn=`Matildas-Menu`!]
E. In the advertisers page, we changed the ’use template’ to ’Custom-Profile’.
Each time ’Matildas’ page is accessed, the snippet call determines which left navigation to use based on the page title. Therefore, in this example, Matilda’s custom left navigation items and advertisements are displayed, rather, than the site default menu items.
Giving advertisers the custom left nav option is now a simple matter of changing the template a page uses to ’Custom-Profile’, creating a copy of the default left nav chunk, and adding an extra snippet call in the ’Custom-Profile’ template for the page description matching the left navigation chunk. So the template might end up looking something like:-
[!tvcnd? &tv=`pagetitle` &cnd=`Matilda, 2` &rtn=`Matildas-Menu`!]
[!tvcnd? &tv=`pagetitle` &cnd=`Martha, 2` &rtn=`Marthas-Menu`!]
[!tvcnd? &tv=`pagetitle` &cnd=`Jack, 2` &rtn=`Jacks-Menu`!]
While this is entry level, the snippet Mark created has some powerful and wide ranging applications for conditional actions based on ’just’ a pages description. We elected this method since we have a custom back end for access and administration of advertiser details, custom links is an enhancement of features available to advertisers which they themselves can maintain, and we can moderate, before it’s passed back to MODx.
-SB