Location: PHPKode > projects > Hero > hero_os/user_guide/designers/smarty.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title>The Smarty Template Engine | Hero User Guide</title>
		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
		<script type="text/javascript" src="./../js/shCore.js"></script>
		<script type="text/javascript" src="./../js/shBrushPhp.js"></script>
		<script type="text/javascript" src="./../js/shBrushXml.js"></script>
		<script type="text/javascript" src="./../js/user_guide.js"></script>
		<link href="./../css/user_guide.css" media="screen" rel="stylesheet" type="text/css" />
		<link href="./../css/shCore.css" media="screen" rel="stylesheet" type="text/css" />
		<link href="./../css/shThemeDefault.css" media="screen" rel="stylesheet" type="text/css" />
	</head>
	<body>
		<div class="header">
			Hero <span class="sub">/ User Guide</span>
		</div>
		<div class="body">
			<div id="navigation">
				<ul>
					<li>
						<a rel="basic" class="parent" href="#">Basic Details</a>
						<ul>
							<li>
								<a href="./../index.html">Welcome to Hero</a>
							</li>
							<li>
								<a href="./../license.html">License Agreement</a>
							</li>
							<li>
								<a href="./../changelog.html">Changelog</a>
							</li>
						</ul>
					</li>
					<li>
						<a rel="installation" class="parent" href="#">Installation</a>
						<ul>
							<li>
								<a href="./../installation/server_requirements.html">Server Requirements</a>
							</li>
							<li>
								<a href="./../installation/installation.html">Fresh Installation</a>
							</li>
							<li>
								<a href="./../installation/upgrading.html">Upgrading</a>
							</li>
							<li>
								<a href="./../installation/migration.html">Migration</a>
							</li>
							<li>
								<a href="./../installation/troubleshooting.html">Troubleshooting</a>
							</li>
							<li>
								<a href="./../installation/deployment.html">Mass Deployment</a>
							</li>
						</ul>
					</li>
					<li>
						<a rel="configuration" class="parent" href="#">Configuration</a>
						<ul>
							<li>
								<a href="./../configuration/settings.html">Settings</a>
							</li>
							<li>
								<a href="./../configuration/coupon_codes.html">Coupon Codes</a>
							</li>
							<li>
								<a href="./../configuration/branding.html">Custom Branding</a>
							</li>
							<li>
								<a href="./../configuration/custom_fields.html">Custom Fields</a>
							</li>
							<li>
								<a href="./../configuration/emails.html">Emails</a>
							</li>
							<li>
								<a href="./../configuration/importing_members.html">Importing Members</a>
							</li>
							<li>
								<a href="./../configuration/member_groups.html">Member Groups</a>
							</li>
							<li>
								<a href="./../configuration/payment_gateways.html">Payment Gateways</a>
							</li>
							<li>
								<a href="./../configuration/reports.html">Reports</a>
							</li>
							<li>
								<a href="./../configuration/search.html">Search</a>
							</li>
							<li>
								<a href="./../configuration/security.html">Security</a>
							</li>
							<li>
								<a href="./../configuration/shipping.html">Shipping Rates</a>
							</li>
							<li>
								<a href="./../configuration/subscriptions.html">Subscriptions</a>
							</li>
							<li>
								<a href="./../configuration/taxes.html">Taxes</a>
							</li>
							<li>
								<a href="./../configuration/advanced.html">Advanced</a>
							</li>
						</ul>
					</li>
					<li>
						<a rel="publishing" class="parent" href="#">Publishing</a>
						<ul>
							<li><a href="./../publishing/blogs.html">Blogs</a></li>
							<li><a href="./../publishing/content.html">Content &amp; Content Types</a></li>
							<li><a href="./../publishing/forms.html">Forms</a></li>
							<li><a href="./../publishing/menus.html">Navigation Menus</a></li>
							<li><a href="./../publishing/rss_feeds.html">RSS Feeds</a></li>
							<li><a href="./../publishing/store.html">Store Products &amp; Collections</a>
							<li><a href="./../publishing/topics.html">Topics</a></li>
						</ul>
					</li>
					<li>
						<a rel="designers" class="parent active" href="#">Designing</a>
						<ul>
							<li><a href="./../designers/index.html">Designer Introduction</a></li>
							<li><a href="./../designers/smarty.html">Smarty Template Engine</a></li>
							<li><a href="./../designers/includes.html">Stylesheets &amp; JavaScript</a></li>
							<li><a href="./../designers/template_plugins.html">Template Plugins</a></li>
							<li><a href="./../designers/mapping_urls.html">Mapping URL's</a></li>
							<li class="reference">Reference</li>
							<li class="reference"><a href="./../designers/reference/global_variables.html">Global Variables</a></li>
							<li class="reference"><a href="./../designers/reference/global_plugins.html">Global Plugins</a></li>
							<li class="reference"><a href="./../designers/reference/blogs.html">Blogs &amp; Archives</a></li>
							<li class="reference"><a href="./../designers/reference/custom_fields.html">Custom Fields</a></li>
							<li class="reference"><a href="./../designers/reference/forms.html">Forms</a></li>
							<li class="reference"><a href="./../designers/reference/members.html">Members</a></li>
							<li class="reference"><a href="./../designers/reference/menus.html">Navigation Menus</a></li>
							<li class="reference"><a href="./../designers/reference/paywall_privileges.html">Access Restrictions &amp; Paywalls</a></li>
							<li class="reference"><a href="./../designers/reference/publish.html">Published Content &amp; Topics</a></li>
							<li class="reference"><a href="./../designers/reference/rss_feeds.html">RSS Feeds</a></li>
							<li class="reference"><a href="./../designers/reference/search.html">Search Forms &amp; Results</a></li>
							<li class="reference"><a href="./../designers/reference/store.html">Store Products &amp; Collections</a></li>
							<li class="reference"><a href="./../designers/reference/subscriptions.html">Subscriptions</a></li>
							<li class="reference"><a href="./../designers/reference/custom_fields.html">Custom Fields</a></li>
						</ul>
					</li>
					<li>
						<a rel="developers" class="parent" href="#">Developing</a>
						<ul>
							<li><a href="./../developers/index.html">Developer Introduction</a></li>
							<li><a href="./../developers/codeigniter.html">CodeIgniter</a></li>
							<li><a href="./../developers/standards.html">Standards &amp; Best Practices</a></li>
							<li><a href="./../developers/security.html">Security</a></li>
							<li><a href="./../developers/modules.html">Module Development</a></li>
							<li><a href="./../developers/template_plugins.html">Template Plugin Development</a></li>
							<li><a href="./../developers/cronjobs.html">Cronjobs &amp; Automated Processes</a></li>
							<li><a href="./../developers/forms.html">Forms &amp; Custom Fieldtypes</a></li>
							<li><a href="./../developers/errors_logging.html">Errors &amp; Logging</a></li>
							<li><a href="./../developers/profiling.html">Debug/Profile Mode</a></li>
							<li class="reference">Reference</li>
							<li class="reference"><a href="./../developers/reference/admin_form_library.html">Admin Form Library</a></li> 
							<li class="reference"><a href="./../developers/reference/admin_navigation_library.html">Admin Navigation Library</a></li> 
							<li class="reference"><a href="./../developers/reference/app_hooks_library.html">App Hooks Library</a></li>
							<li class="reference"><a href="./../developers/reference/array_to_csv_library.html">Array to CSV Library</a></li> 
							<li class="reference"><a href="./../developers/reference/array_to_json_helper.html">Array to JSON Helper</a></li> 
							<li class="reference"><a href="./../developers/reference/blog_model.html">Blog Model</a></li> 
							<li class="reference"><a href="./../developers/reference/cart_model.html">Cart Model</a></li> 
							<li class="reference"><a href="./../developers/reference/clean_string_helper.html">Clean String Helper</a></li> 
							<li class="reference"><a href="./../developers/reference/collections_model.html">Collections Model</a></li> 
							<li class="reference"><a href="./../developers/reference/content_model.html">Content Model</a></li>
							<li class="reference"><a href="./../developers/reference/content_type_model.html">Content Type Model</a></li>  
							<li class="reference"><a href="./../developers/reference/coupon_model.html">Coupon Model</a></li> 
							<li class="reference"><a href="./../developers/reference/custom_fields_model.html">Custom Fields Model</a></li> 
							<li class="reference"><a href="./../developers/reference/dataset_library.html">Dataset Library</a></li> 
							<li class="reference"><a href="./../developers/reference/email_model.html">Email Model</a></li> 
							<li class="reference"><a href="./../developers/reference/fieldtype_library.html">Fieldtype Library</a></li> 
							<li class="reference"><a href="./../developers/reference/form_builder_library.html">Form Builder Library</a></li> 
							<li class="reference"><a href="./../developers/reference/form_model.html">Form Model</a></li> 
							<li class="reference"><a href="./../developers/reference/image_thumb_helper.html">Image Thumb Helper</a></li>
							<li class="reference"><a href="./../developers/reference/invoice_model.html">Invoice Model</a></li> 
							<li class="reference"><a href="./../developers/reference/head_assets_library.html">Head Assets Library</a></li> 
							<li class="reference"><a href="./../developers/reference/link_model.html">Link Model</a></li> 
							<li class="reference"><a href="./../developers/reference/login_model.html">Login Model</a></li> 
							<li class="reference"><a href="./../developers/reference/menu_model.html">Menu Model</a></li> 
							<li class="reference"><a href="./../developers/reference/notices_library.html">Notices Library</a></li>
							<li class="reference"><a href="./../developers/reference/order_model.html">Order Model</a></li>  
							<li class="reference"><a href="./../developers/reference/products_model.html">Products Model</a></li> 
							<li class="reference"><a href="./../developers/reference/usergroup_model.html">Usergroup Model</a></li> 
							<li class="reference"><a href="./../developers/reference/product_option_model.html">Product Option Model</a></li>
							<li class="reference"><a href="./../developers/reference/rss_model.html">RSS Model</a></li> 
							<li class="reference"><a href="./../developers/reference/setting_helper.html">Setting Helper</a></li>
							<li class="reference"><a href="./../developers/reference/settings_model.html">Settings Model</a></li> 
							<li class="reference"><a href="./../developers/reference/shipping_model.html">Shipping Model</a></li> 
							<li class="reference"><a href="./../developers/reference/states_model.html">States Model</a></li> 
							<li class="reference"><a href="./../developers/reference/stats_library.html">Stats Library</a></li> 
							<li class="reference"><a href="./../developers/reference/subscription_model.html">Subscription Model</a></li> 
							<li class="reference"><a href="./../developers/reference/subscription_plan_model.html">Subscription Plan Model</a></li> 
							<li class="reference"><a href="./../developers/reference/taxes_model.html">Taxes Model</a></li> 
							<li class="reference"><a href="./../developers/reference/template_files_helper.html">Template Files Helper</a></li> 
							<li class="reference"><a href="./../developers/reference/theme_model.html">Theme Model</a></li>
							<li class="reference"><a href="./../developers/reference/time_since_helper.html">Time Since Helper</a></li> 
							<li class="reference"><a href="./../developers/reference/topic_model.html">Topic Model</a></li> 
							<li class="reference"><a href="./../developers/reference/url_helper.html">URL Helper</a></li> 
							<li class="reference"><a href="./../developers/reference/user_model.html">User Model</a></li> 
							<li class="reference"><a href="./../developers/reference/usergroup_model.html">Usergroup Model</a></li> 
						</ul>
						
					</li>
				</ul>
			</div>
			<div id="content">
				<h1>The Smarty Template Engine</h1>

<p>Hero is powered by the <a href="http://www.smarty.net">Smarty Template Engine</a>.  This means that its templates follow the same syntax and structure of Smarty templates, that all standard Smarty template plugins and modifiers are available in our templates, and that your site's templates are parsed, cached, and displayed by the latest release of Smarty.</p>

<p>Smarty is open source software, written by the founding developers of the PHP programming language.  Hero uses the latest release of its software, version 3.  This version is faster than ever before and optimized for web servers that use PHP5.</p>

<h2>What You Need to Know</h2>

<p>You don't need to know much about Smarty to begin using it in your Hero templates.  It's just like any templating language.  Instead of exporting HTML directly from the software, we make a bunch of variables and plugins available to designers to use in their HTML/Smarty template files.  This gives designers absolute control over what is displayed to the end user.</p>

<p>In order to use Smarty, you should understand the following:</p>

<ul>
<li>You don't need to install anything extra to use Smarty.  Smarty files can be edited in any text editor.  Smarty files are basic HTML files and you can link to JavaScript, CSS stylesheets, and other files just like you would in any other web design.</li>
</ul>

<ul>
<li>You have 100% control over the HTML displayed to the end user, because you can customize any template and customize which template is displayed for specific content, etc.</li>
</ul>

<ul>
<li><strong>Template variables</strong> are placed in template files so that they can be dynamically replaced by data when the web page loads.  For example, we can use one template to display 1000's of blog posts because, instead of writing the blog posts' titles in the template, we use a tag like <span class="code">{$title}</span> in place of the title.  (<a href="http://www.smarty.net/docs/en/language.syntax.variables.tpl">official documentation</a>).</li>
</ul>

<ul>
<li><strong>Template plugins</strong> (<a href="./../designers/template_plugins.html">more information here</a>) bring advanced functionality to templates, whether you are loading content from your database with the <span class="code">{$content}</span> plugin (<a href="./../designers/reference/publish.html">documentation here</a>) or displaying an absolute URL (e.g., <span class="url">http://www.example.com/user/register</span>) from a relative path with <span class="code">{url path=&quot;user/register&quot;}</span> (<a href="./../designers/reference/global_plugins.html">documentation here</a>).  Official documentation on Smarty functions <a href="http://www.smarty.net/docs/en/language.syntax.functions.tpl">begins here</a> and <a href="http://www.smarty.net/docs/en/language.syntax.attributes.tpl">here</a>.</li>
</ul>

<ul>
<li><strong>Comments</strong> are denoted like so, and are completely ignored in your template file: <span class="code">{* This is a comment *}</span> (<a href="http://www.smarty.net/docs/en/language.basic.syntax.tpl">official documentation</a>).</li>
</ul>

<ul>
<li>Sets of data are <strong>looped</strong> through with the <span class="code">{foreach}</span> syntax (<a href="http://www.smarty.net/docs/en/language.function.foreach.tpl">official documentation</a>).</li>
</ul>

<ul>
<li><strong>Conditionals</strong> follow typical if/else structure: <span class="code">{if $test == &quot;1&quot;}Yes!{else}No!{/if}</span>.  Can also use elseif: <span class="code">{if $person == &quot;Mike&quot;}You are Mike{elseif $person == &quot;Paul&quot;}You are Paul{else}You are neither Mike nor Paul.  Who are you?{/if}</span>.</li>
</ul>

<ul>
<li>You can <strong>assign values</strong> to new template variables with the <span class="code">{assign}</span> function (<a href="http://www.smarty.net/docs/en/language.function.assign.tpl">official documentation</a>).</li>
</ul>

<ul>
<li>If you are really digging into the templates and want to restructure your theme's template directory, you will need to have a basic knowledge of <strong>template inheritance</strong> (<a href="http://www.smarty.net/inheritance">official documentation</a>).</li>
</ul>

<h2>How to Learn More</h2>

<p>If you are confused about Smarty, want to learn the syntax, or want to know more about all the <strong>default Smarty plugins, functions, and modifiers</strong>, the best place to start is at their comprehensive <a href="http://www.smarty.net/docs/en/">documentation site</a>.</p>

<p>All template plugins that are not part of Smarty but come as part of Hero are documented in this documentation for designers, in the Reference section.</p>
			</div>
		</div>
	</body>
</html>
<!-- /designers-->
Return current item: Hero