web technology is a way of life
27 Feb
I’ve found a little problem with MODx and transferring data to a snippet and using it in a string comparison. The issue arises when you call a snippet from within a page (in the [*content*] portion). There is also an issue when passing a MODx var in a snippet parameter. In order to overcome this issue, I’ve needed to create two snippets, one called within the template and another that can be called in the text of [*content*] and get the data from the first snippet.
1. Create a snippet called [[setup]] with this code:
$modx-vars = Array();
$modx->vars['alias'] = $alias;
2. Create another snippet called [[nav]] which would have code like this that would give a class to a navigation link for example:
$alias = $modx->vars['alias'];
echo $alias == 'index'? ' class="current"': '';
3. Then we’ll need a template with this code:
[[setup?alias=[*alias*]&done]]
[*content*]
Note: In the call to [[setup]] we end with &done since the triple end brackets ] cause a problem of their own.
4. Finally create a page with this content:
[[nav]]
Now you can use the $modx->vars array to pass any data you need from one snippet to others when you need to use that data for actual string comparison, manipulation or usage that would otherwise only be accessible after MODx performs a php eval.
The Livescribe Pulse smartpen gets an app store. This little pen is quite amazing, and it just shows that the business model of an app store is already changing the market for every type of electronic device. So when does my…
The Ghostwire (DSiWare) game looks great and reminds me a lot of Fatal Frame.
FloorPlanner is an interesting bit of software built in Flash that allows you design your home in 2D and view in 3D.
The new Stargate Universe [Philosphocal] teaser looks awesome. I stopped watching Atlantis a bit ago because it got boring, I hope this pumps up the energy as BSG did. It has Lou Diamond Philips and Ming-Na in it, that could make…
Here’s a plethora of well designed RSS Feed icons for free!