Views
- Adroit views are powered by the popular and powerful Smarty Template Engine. For more information about specific Smarty syntax and tags, please visite their website.
- Aside from the standard Smarty templating system, Adroit does provide some nice features when it comes to creating your views. Views map directly to controller action methods. For more information on controllers, please visit the controllers section. Every controller class should have a correlating directory in the app/view/ location that houses views for that particular controller. For example, if you have a controller, TestController, you would have a directory structure such as app/view/test/ where your views would reside.
- If you are creating a view that maps to a url such as www.mytestsite.com/test/register/, it would call the TestController.registerAction() method, which would then load the app/view/test/register.tpl view template.
- Adroit will load the view corresponding to the current request into a variable, $bodyTpl, that is placed in the main layout template. If you run the AppBuilder, a default template, app/view/layouts/base.tpl is created for you, and you can see that it contains {$bodyTpl} to render the specific action methods view into the main layout. One unique feature of Adroit is that if an XHR (ajax) request is made, by default it will render the specific action methods view as a partial, meaning that it won't render the complete layout template with the action view inside of it. It will only render the action methods view by itself. This is extremely useful for creating an ajax enhanced website that will share the same action methods and views for a user that is using your ajax interface with javascript, or perhaps not using javascript (such as a search engine). This site takes advantage of that feature of Adroit. You will notice that as you navigate around, requests are made asynchronously, loading in the new content into the main area for that specific action method and its view. If you turn javascript off in your browser, the site will continue to behave normally, but without the ajax requests. This is a very powerful piece of Adroit, and helps greatly in quickly creating ajax powered websites in a manageable and organized way.
- A very nice feature of Smarty is the ability to use tempate configuration files. This is a file where you can assign different configuration attributes for your templates, such as page titles, meta tag values, page specific values, or any other flags that may be useful in your templates, but you want to keep them abstracted into a configuration file. Adroit uses the file app/view/template-config.conf for the Smarty configuration file. Here you can load in whatever values your specific website needs. Smarty config files allow you to create "sections" that can be loaded for different pages. For more information on that, visit this link. Adroit will by default, try and load a section named according to the current "package" (subdirectory for your controller), "controller", and "action". If I had a specific page that was mapped to a TestController.registerAction, Adroit would attempt to load the [TestRegister] section. If TestController as in an "admin" subdirectory, it would try and load the [AdminTestRegister] section.


