Skip to content

Instantly share code, notes, and snippets.

@gbrock
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbrock/048d66616e08a93f2d25 to your computer and use it in GitHub Desktop.
Save gbrock/048d66616e08a93f2d25 to your computer and use it in GitHub Desktop.
A basic HTML5 template for starting CodeIgniter projects
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* HTML5 Template for CodeIgniter
*
* @author gBrock
*
* Sets up a basic HTML5 document with some sensible setup,
* also allowing you to pass arrays of CSS and JS files as
* well as a view from your controller, which will be loaded
* into the <body>.
**/
$this->load->helper('html');
$this->load->helper('url');
echo doctype('html5')."\n";
?>
<html>
<head>
<title><?php
if(isset($sTitle) && is_string($sTitle))
{
echo htmlentities( // & becomes &amp;
html_entity_decode( // &amp; becomes &
$sTitle
)
);
}
?></title>
<?php
// render our <link> tags (CSS)
if(isset($aCSS) && is_array($aCSS) && count($aCSS))
{
foreach($aCSS as $sScript)
{
echo "\n\t".link_tag('index.php/includes/css/' . $sScript . '.css');
}
}
?>
</head>
<body>
<?php
// render our layout file, which itself will render the inner page
if(isset($sView) && is_string($sView) && strlen($sView) > 0)
{
$sHTML = $this->load->view(
$sView // the view file
, NULL // the view will have access to the same variables passed to this file
, TRUE // return the rendered layout/view
);
echo $sHTML;
}
?>
<?php
// render our <script> tags (JS)
if(isset($aJS) && is_array($aJS) && count($aJS))
{
foreach($aJS as $sScript)
{
echo "\n\t".'<script src="' . site_url('includes/js/' . $sScript . '.js') . '"></script>';
}
}
?>
</body>
</html>
<?php
/* End of file html5.php */
/* Location: ./application/views/html5.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment