-
Controller Assets
Assets organize content in a document. Assets are called by the main template (e.g. default.master.tpl) which renders the content currently stored in them. Assets are managed with code via plugins or the theme hooks file. Default assets Vanilla uses these assets by default: Head, Content, Panel, and Foot. You cannot rely…
-
Using a Smarty Master View
Smarty Master View This master view acts as the wrapper for each page in your theme. Often, this is the only view you'll have to manipulate. The master view file is called the default.master.tpl (Smarty template) or the default.master.php. We recommend using Smarty templates for your master view, however you can decide to…
-
Twig Overview
Twig is the preferred view rendering system in Vanilla's PHP codebase since version 3.0. It offers a few notable improvements over Smarty or creating views directly in PHP. Automatic escaping/sanitization of content (more secure). More efficient rendering (faster). Better developer documentation (more community support).
-
View Helper Functions
This is a quickstart guide to some of Vanilla’s globally available functions and methods. Familiarizing yourself with them will save you time and effort in the long term, and give you clues about how best to use the framework. This is by no means an exhaustive list, nor full signature documentation. You’ll want to find…
-
Smarty Overview
Smarty Overview Vanilla currently supports both PHP and Smarty views. Smarty is a template engine that allows dynamic content to be inserted into a HTML template using tags. These tags are wrapped in curly braces: {tag}, and can represent variables or the output of a function call. They are replaced when the page is…
-
How To Render a Twig View
There are multiple contexts in Vanilla where you may want to render a twig view. In a Gdn_Controller This is very easy. Follow the rules for naming views as defined in our views documentation. Then use the file extension .twig instead of .php . View overrides, lookup, etcetera, all work exactly the same as with a PHP or…
-
Legacy View Lookup
Once a controller method is called to handle the request, how is the xhtml of the page put together? Views. There are two types of views in Garden: “Views” and “Master Views”. A view relates directly to the controller method that called it and handles rendering content related to that request. You can typically think of a…
-
Smarty Conditionals
Smarty includes a base amount of logic that you can insert into your template. One of these is a conditional statement. A couple of basic examples should give you an idea of the syntax and format of Smarty conditionals. This example uses the user data from the controller’s data array to print out a welcome message if the…
-
Twig Tips & Tricks
Here are a few simple tips to get the most out of Twig views. Handling null or undefined values In development, Twig will give fatal errors when accessing an undefined value. This is to make the developer more aware of the content being injected into their view, and to more easily identify typos. In production these will…
-
Gdn_Module
If controller methods represent the main content/purpose of a page, modules represent secondary information or functions. Modules are small groupings of functionality or information on a page. Some modules that are bundled with Garden include: HeadModule - Allows addition of javascript, css & meta information to be…