Mark Martin KiaIn case you missed my earlier post, Create A User Config Page in MODx, I thought I would describe another practical example of how we have used this Config Page technique on a recent project. My goal here is to demonstrate a simple technique that is continuing to provide a lot of design flexibility for MODx projects, it’s potential applications are broad.

Our customer, a new car dealer, has a third party service that dumps data onto our servers. It is inventory information that we parse out onto a New Inventory page. It is not my intent to describe the snippet that we (thanks @swscripts) built to accomplish this, but to describe how we used this Config Page technique to give the client more control of their site/data.

One of the custom snippet functions we created took the price of a new car and applied the appropriate mathematics so that an estimated monthly payment would be output against any given vehicle in the database. In order to do this the calculations required a price (which we already had from the database dump), terms (months), interest rate (per cent) and down payment (per cent).

We created 3 new Template Variables (TVs): interest, down and terms which were then assigned to the Config template. Once created, all the customer has to do is change any of these Config Page fields to control the output of the estimated vehicle payment on the New Vehicles page.

Now, in order to use them in our custom snippet we called on the getField snippet inside our own snippet (see below):

// values for payment calculation
$invTerm = $modx->runSnippet("GetField",array("docid" => "1","field" => "terms")); // terms in months
$invRate = $modx->runSnippet("GetField",array("docid" => "1","field" => "interest")); // interest rate per cent as decimal
$invDown = $modx->runSnippet("GetField",array("docid" => "1","field" => "down")); // down payment per cent as decimal

After all this was in place we used the ManagerManager snippet to create a new tab on our Config template called Estimated Payment Variables. We then moved our TVs into the tab for a clean presentation. You can see this in action on Mark Martin Kia.

  • buddyrigotti

    Nice. I'm using the config page for churches. This is a much simpler approach with mostly text fields as template variables, but this allows the church to update their address and phone number in case it changes, as well as other variables such as paypal email address (for online donations), Google calendar email address, and so on. It's works great!

  • http://www.nikemaxsale.com nike air max

    “your details is really reasonable and unique I very concerned about sports and I imogen-heap believe only sports can make you energetic. I want to buy some sports thing ,will you give some suggestions nike air max for me from below websites ?

  • Pingback: Creating a User Config Page in Revo | Greg Smart