Creating Custom Modules
When you added a poll to a module and included a menu in a module, you created a custom (albeit simple) module (i.e., a user module) instead of selecting a pre-defined module. In addition to adding Tiki objects (such as polls and menus) to modules, you can use HTML or Smarty syntax as well.
Tip
Using HTML
You can add custom HTML to a module. This allows you to add widgets, application, and scripts from other sources. For example, you can add an automatic weather forecast (fromThe Weather Network) to a Tiki module. Simply create a new module and add the HTML code:
<div id="plemx-root"></div> <a href="http://www.theweathernetwork.com">The Weather Network</a> <script type="text/javascript"> var _plm = _plm || []; _plm.push(['_btn', 94593]); _plm.push(['_loc','usny0996']); _plm.push(['location', document.location.host ]); (function(d,e,i) { if (d.getElementById(i)) return; var px = d.createElement(e); px.type = 'text/javascript'; px.async = true; px.id = i; px.src = ('https:' == d.location.protocol ? 'https:' : 'http:') + '//widget.twnmm.com/js/btn/pelm.js?orig=en_ca'; var s = d.getElementsByTagName('script')[0]; var py = d.createElement('link'); py.rel = 'stylesheet' py.href = ('https:' == d.location.protocol ? 'https:' : 'http:') + '//widget.twnmm.com/styles/btn/styles.css' s.parentNode.insertBefore(px, s); s.parentNode.insertBefore(py, s); })(document, 'script', 'plmxbtn');</script>
Use the Custom Modules tab on the Admin: Modules page to create a new, custom module:
- In the Data area, paste the code from the widget.
- In the Parse Using field, select None.
- Click Create. Tiki prompts for confirmation, then saves the information and displays the newly created module in the Custom Modules list. Your custom module:
- To display the module in a column, select Actions > Assign. The Assign/Edit modules tab appears.
- Complete the fields as shown in the Adding Modules section.
The module includes the weather report for New York, USA:
Including Smarty
You can include Smarty syntax in your modules to do all sorts of neat things, such as displaying Tiki variables. For example, using this code:
Hello {if $user}{$user}{else}anonymous visitor{/if}!
will create a module that:
- If the user is logged in, the module will show:
Hello the user's name! - If the user is not logged in, the module will show:
Hello anonymous visitor!
Warning
Refer to this troubleshooting tip if Tiki displays a message indicating a Fatal Smarty error.