The variables that can be used in the html templates are listed next. Each of these variables can be used by putting them in curly brackets and prefix with $ Example: {$pgb_image_dir}
For the php styles the same variables exist, but the have to be prefixed by $tpl. Example: $tpl_pgb_image_dir. Language Constans are a exception (sorry :-) to this rule, they are accessed by using '_' as prefix. Example: _PGB_CAP_CANCEL.
JavaSript in Smarty can be included in a {literal} {/literal} block. Text within this block is not parsed by smarty -> { and } can be used without problems.
Encompass uses [- and -] as delimiters which also makes { and } available for free use.
Example 4-2. using JavaScript in Smarty
{literal}
<script type="text/javascript">
<!--
function insertSmilie(aSmilie)
{
var message_ctrl = document.pgb_form.pgb_message;
message_ctrl.value= message_ctrl.value + aSmilie;
message_ctrl.focus();
return false;
}
-->
</script>
{/literal}
|
Table 4-1. Language Constants
| Variable | Meaning |
|---|---|
| PGB_CAP_CANCEL | Cancel |
| PGB_CAP_CHANGE | Change |
| PGB_CAP_EMAIL | |
| PGB_CAP_HOMEPAGE | Homepage |
| PGB_CAP_LOCATION | Location |
| PGB_CAP_MESSAGE | message |
| PGB_CAP_NAME | name |
| PGB_CAP_PREVIEW | preview |
| PGB_CAP_SIGN | sign |
| PGB_CAP_DISABLE_BBCODE | |
| PGB_CAP_DISABLE_HTML | |
| PGB_CAP_DISABLE_AUTOLINKS | |
| PGB_CAP_COMMENT | |
| PGB_CREATE_ENTRY | create |
| PGB_EMAIL | |
| PGB_ENTRY_COUNT_MSG | |
| PGB_FROM | |
| PGB_HOMEPAGE | |
| PGB_ON_DATE_FORMAT | |
| PGB_PAGE' | |
| PGB_TITLE | |
| PGB_TITLE_ADD_ENTRY | |
| PGB_TITLE_PREVIEW | |
| PGB_WELCOME_MSG | |
| PGB_WROTE |
Table 4-2. global available template variables
| Variable | Meaning |
|---|---|
| style | Name of the current style/theme |
| entries | List of entries, Instances of class entry |
| entry | actual entry, Instance of class entry |
| entry_count | Number of entries in the list |
| curl_open | } -> {ldelim} can be used for left delimiter |
| curl_close | { -> {rdelim} can be used for right delimiter |
| pgb_image_dir | path to images of current style |
| pgb_moddir | basedirectory of the module |
| isadmin | boolean: is the current user allowed to admin the guestbook |
| lang | current user language, e.g. eng |
| pages | array of page-numbers from 1 to number of pages |
| current_page | number of the current page |
| number_of_pages | total number of pages |
| pgb_admin_delete_url | url for deleting a entry |
| pgb_start_url | URL that leeds to the guestbook |
| pgb_date_format | dateformat for current user |
| pgb_comment | admin comment |
| pgb_error_message | error message |
| pgb_status | status or error message - if error is present overwrites status |
| pgb_status_alert | javascript code presenting a error message in a message box |
| pgb_is_bbcode_enabled | true if bbcode is installed and enabled by admin |
| pgb_is_html_enabled | true if html in posts is enabled |
| pgb_is_autolink_enabled | true if autolinks are enabled |
| rowcolor | array of two colors used for different coloring of odd and even rows |
| bgcolor1 | Theme: bgcolor1 |
| bgcolor2 | Theme: bgcolor2 |
| bgcolor3 | Theme: bgcolor3 |
| bgcolor4 | Theme: bgcolor4 |
| bgcolor5 | Theme: bgcolor5 |
| textcolor1 | Theme: textcolor1 |
| textcolor2 | Theme: textcolor2 |
| opentable | Theme: Result of OpenTable() function |
| closetable | Theme: Result of CloseTable() function |
| opentable2 | Theme: Result of OpenTable2() function |
| closetable2 | Theme: Result of CloseTable2() function |
Note: optentable, opentable2, closetable and closetable2 don't work with Encompass!
The entries for a page of the guestbook are in a array called entries. Each row in this array contains a Instance of the class GuestBookEntry found in pnuserapi.php. The members in this class can be accessed using '->'.
Example 4-3. accessing Class members
<!-- print the name of all postings -->
{foreach from=$entries item=entry name=entries}
{$entry->name}
{/foreach}
|
Table 4-3. member of the GuestBookEntry class
| Member | Meaning |
|---|---|
| id | id, primary key |
| name | name |
| message | message the user want's to post |
| homepage | homepage |
| location | location |
| mood | mood (not used in default style) |
| private_msg | flag for private message (not used till yet) |
| timestamp | timestamp of the posting |
| ip | ip address of the poster, should only be show to admins |
| user1 | content of admin defined field 1 |
| user2 | content of admin defined field 2 |
| user3 | content of admin defined field 3 |
| user4 | content of admin defined field 4 |
| user5 | content of admin defined field 5 |
| disable_html | flag if html is disabled for this entry |
| disable_bbcode | flag if bbcode is disabled for this entry |
| disable_autolinks | flag if autolinks are disabled for this entry |
| pn_user_id | PostNuke User Id, if the post was made by a registered user |
| avatar | avatar of the user (avatar.gif) |
| avatar_img | html code for avatar img <img src="...> |
Variables that can be only be used in entry_submit.tpl and entry_edit.tpl.
Table 4-4. variables only available in new and edit
| Variable | Meaning |
|---|---|
| pgb_id | id, primary key |
| pgb_name | name |
| pgb_message | message the user want's to post |
| pgb_email | |
| pgb_homepage | homepage |
| pgb_location | location |
| pgb_mood | mood (not used in default style) |
| pgb_private_msg | flag for private message (not used till yet) |
| pgb_timestamp | timestamp of the posting |
| pgb_user1 | content of admin defined field 1 |
| pgb_user2 | content of admin defined field 2 |
| pgb_user3 | content of admin defined field 3 |
| pgb_user4 | content of admin defined field 4 |
| pgb_user5 | content of admin defined field 5 |
| pgb_submit_url | url for submitting a entry |
| pgb_disable_html | flag if html is disabled for this entry |
| pgb_disable_bbcode | flag if bbcode is disabled for this entry |
| pgb_disable_autolinks | flag if autolinks are disabled for this entry |
| pgb_pn_user_id | PostNuke User Id, if the post was made by a registered user |
| pgb_avatar | avatar of the user (avatar.gif) |
| pgb_avatar_img | html code for avatar img <img src="...> |
| pgb_bbcode_html | html code for integrating bbcode buttons in edit template.
|
| authid | authentication id for edit template, used in hidden control. Only needed when updating an existing entry. |