Sitemason Boilerplate Template

For beginners and masters alike, the Sitemason Boilerplate template is a great place to start your project. We are constantly improving Sitemason, and we'll make additions to the boilerplate to take advantage of new Sitemason features as they come online. Even if you're a pro and feel real comfortable with Sitemason, it's always a great place to look and see if any major changes or updates have been made that could benefit your project.

If much of this looks familiar, it's not a coincidence. Most of it is influenced by, if not pulled directly from, the fantastic work being done by Paul Irish and crew at www.html5boilerplate.com. Tim Moses at Sitemason has added a significant number of improvements to the Sitemason PHP Library to make implementing much of the boilerplate a breeze, in true Sitemason fashion. You can read all about those additions on the Sitemason Developer Group.

Download the Full Version which includes the html5boilerplate.com full line-by-line documentation of the Sitemason PHP template (as seen below) or just the nuts & bolts Minimum Version. 

 

<?php
require_once('/web/shared/php/1.0/sitemason.inc');

# Load the Main Content XML
# http://developer.sitemason.com/library/methods/getxml.149741
$content = new Content($content_xml);
$content_xml = $content->getXML();

# Load Optional Side Content XML
# http://developer.sitemason.com/library/methods/sidecontent.149750
# $side = new SideContent('http://www.side-content-url.com?toolxml');
# $side_xml = $side->getXML();

# $site_url variable helpful for including assets when redeveloping or working on site without DNS pointed to Sitemason
$site_url = 'http://www.site-url.com';
# prepend the $secure_url variable when including asset files so they are transferred securely when at secure.sitemason.com
$secure_url = $content_xml->secure_image_url;

# use the $layout variable for includes or layout specific functions
if ($content_xml->current_nav->id == 'xxxxxx') {
$layout = 'home';
} else {
$layout = 'interior';
}
?>

<!-- http://developer.sitemason.com/library/methods/printinithtml.149561 -->
<?php $content->printInitHTML('HTML 5'); ?>

<head>
<meta charset="utf-8">

<!-- Use the .htaccess and remove these lines to avoid edge case issues.
   More info: h5bp.com/i/378 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<!-- http://developer.sitemason.com/library/methods/printpagehead.149569 -->
<?php $content->printPageHead(); ?>

<!-- Mobile viewport optimized: h5bp.com/viewport -->
<meta name="viewport" content="width=device-width">

<!-- Place favicon.ico and apple-touch-icon.png in the root directory: mathiasbynens.be/notes/touch-icons -->

<link rel="stylesheet" href="<?php echo $secure_url; ?>/sm_template/css/style.css">

<!-- More ideas for your <head> here: h5bp.com/d/head-Tips -->

<!-- All JavaScript at the bottom, except this Modernizr build.
   Modernizr enables HTML5 elements & feature detects for optimal performance.
   Create your own custom Modernizr build: www.modernizr.com/download/ -->
<script src="<?php echo $secure_url; ?>/sm_template/js/libs/modernizr-2.5.3.min.js"></script>
</head>

<!-- http://developer.sitemason.com/library/methods/printbodytag.149554 -->
<?php $content->printBodyTag(); ?>

<!-- Prompt IE 6 users to install Chrome Frame. Remove this if you support IE 6.
chromium.org/developers/how-tos/chrome-frame-getting-started -->
<!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->
<header>
<!-- http://developer.sitemason.com/library/methods/printnavaslist.149568 -->
<?php $content->printNavAsList(); ?>
</header>
<div role="main">
<!-- http://developer.sitemason.com/library/methods/printcontent.149744 -->
<?php $content->printContent(); ?>
</div>
<footer>
<!-- In addition to using the library, you can always parse the XML directly
http://developer.sitemason.com/parsing_xml_php#Retrieving_a_Single_Value_from_XML -->
<?php echo $content_xml->footer; ?>
</footer>
<!-- Thanks for the props! -->
<div id="sitemason"><span>Built on </span><a href="http://www.sitemason.com">SITEMASON</a></div>

<!-- JavaScript at the bottom for fast page loading -->

<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="<?php echo $secure_url; ?>/sm_template/js/libs/jquery-1.7.1.min.js"><\/script>')</script>

<!-- scripts concatenated and minified via build script -->
<script src="<?php echo $secure_url; ?>/sm_template/js/plugins.js"></script>
<script src="<?php echo $secure_url; ?>/sm_template/js/script.js"></script>
<!-- end scripts -->

<!-- http://developer.sitemason.com/library/methods/printbodylast.149552 -->
<?php $content->printBodyLast(); ?>
</body>
</html>

 

Change Log

4/25/2012 v0.4

  • Upgraded to html5boilerplate.com version 3
  • Removed $isMobile stylesheet switching in favor of responsive style methods
  • Added $site_url, $secure_url and $layout variables
  • Made template secure when at secure.sitemason.com
  • Changed Sitemason props to new slogan, "Built on SITEMASON"

7/29/2011 v0.3

  • Added minimal version in addition to full version. Full version contains per-line documentation and test directory using Quint, while minimal version has no documentation, deletes test directory as well as references to plugin.js & script.js.
  • Moved all files to parent /sm_template directory and updated all relative URLs
  • Renamed primary template file to template.php
  • Updated for html5boilerplate v1
  • Updated documentation links to developer.sitemason.com
  • Reworked stylesheet <link> based on isMobile

2/21/2011 v0.22

  • Changed main Content call to $content = new Content($content_xml); on line 6 in order to support Sitemason's new system wide caching service.

9/23/2010 v0.21

  • Moved jQuery to the top. Loading at the bottom only works if you can add your sub-functions below the initial call, which when working with interior templates, often isn't possible.
  • Added jQuery Tools as option for loading jQuery. Sitemason often uses jQuery Tools for projects, so we added it to our boilerplate.  Please note you cannot use both.
  • Removed pink selection color. It's cool and all, but isn't appropriate for most projects. 

9/20/2010 v0.2

  • Added support for $isMobileBrowser() method
  • Added variable setting $isMobile to boolean value of $isMobileBrowser
  • Use $isMobileBrowser to print mobile stylesheet
  • Moved meta viewport inside of $isMobileBrowser IF statement
  • Adds screen.css IF NOT mobile browser, but not necessary if relying on style.css for screen styles

9/7/2010 v0.11

  • "Conditional Comments Block Downloads" <!--[if IE]><![endif]--> removed from Boilerplate and added to printPageHead()
  • Moved forced Chrome rendering in IE meta tag to printPageHead. Was set in Apache and caused problems with some sites optimized for < IE8
  • All IE specific hacks in PHP Library only show up in IE. Sitemason handles browser detection.  
  • Missing preceding slash (/) for local jQuery fallback location
  • Added Sitemason logos URL to props div http://logo.sitemason.com

9/3/2010 v0.1

Launched! When we start a new project over at Sitemason, we usually begin with a simple boilerplate template. Emulating the great work at html5boilerplate.com, we decided to give ours a shot of steroids, document & publish to the website for the benefit of all Sitemason developers. Enjoy, and send all comments/questions to developer-group@sitemason.com.

110 30th Ave North, Suite 5 | Nashville, TN 37203 | 615-301-2600 | 888-349-5578