Skip to content
Sitemason - Build on Us

Developer Tips: Custom Queries for Live Testing

Today we're launching a new series for developers to regularly offer tips and tricks for developing in the Sitemason environment. Our first tip is to use custom queries for testing code on a live site. 

One thing that is very different for developers working on the Sitemason platform for the first time is developing in a live production environment. Sitemason is a cloud service after all. This is generally only an issue for redeveloping an existing Sitemason sites. One trick for working on a site without affecting the production version is to use custom queries. 

Sitemason will add any URL query to the site XML at $content_xml->current_nav->form. So by simply adding your own query to the site path like you can key off of $content_xml->current_nav->form->preview to switch between live and production templates. 

For example, a simple switch might look like this:

if ($content_xml->current_nav->form->preview) {
} else {

This then rings true for any piece of the template. For example, if you simply wanted to test adding a callout to a layout, you could do something like:

if ($content_xml->current_nav->form->preview) {
     echo '<div class="callout">Some content here.</div>';

Or for A/B Testing:

if ($content_xml->current_nav->form->test1) {
     echo '<h2>Larger Title</h2>';
} elseif ($content_xml->current_nav->form->test2) {
     echo '<h4>Smaller Title</h2>';
} else {
     echo '<h3>Current Title</h2>';


Billy White headshot thumbnail

Billy is a web developer and Chief Product Officer (CPO) at Sitemason, and has been with the company since 2006.  Read more about Billy White.

Contact Billy:

Recent Forum Posts

Warning: file_get_contents( failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /mnt/files/s/ on line 11 Warning: usort() expects parameter 1 to be array, null given in /mnt/files/s/ on line 14 Warning: Invalid argument supplied for foreach() in /mnt/files/s/ on line 17