Portal Administration Guide : Customize Xinet Portal : Customized tags

Customized tags
Xinet Portal comes with an extensive list of existing tags for use in customizing the Xinet Portal templates. (See Appendix: Xinet Portal Tags and Templates.) Sometimes it may be necessary, however, to enhance an end-users experience by introducing new data or action buttons not present in the default tags. This section discuss adding Variable Data Tags in both the base Xinet Portal template page and an array of files.
Adding a General Page tag
Dynamic and/or static data of all kinds may added to the body area of a Xinet Portal template. This is done by adding a simple script to the local.inc.php file found with the templates of a Xinet Portal Web site. In this example we will add the user’s name and date to a tag as a welcome banner. Once this script is added to the local.inc.php file, it can be used in any of the templates associated with the current Xinet Portal Web site. To add the functionality to another Xinet Portal Web site, simply copy the script to another Xinet Portal Web site’s local.inc.php file.
Example: Creating a welcome banner
Goal: To display a welcome banner for each user.
Customization method: Create a new string, $banner, inside the local.inc. php file, build a new Variable Data Tag, and use it in the toplevel.tmpl.html file.
For use with:Exhibit-style sites.
Directions:
To create a script that will display a welcome banner we will use Xinet Portal data to provide the user’s name and the PHP date() function to generate the current date. Refer to the PHP manual (http://www.php.net/manual/) for the use of date().
1.
 
<?php
 
/* */
/* Create $banner string to include user name and current date */
/* */
 
$banner = "Welcome " . $tmpl->USERINFO['USER'] . ", the current date is " . date("F j, Y");
 
/* */
/* Assign $banner strings to the Variable Data Tag */
/* named "BANNER" Note: the Variable Data Tag MUST be in all UPPER CASE letters */
/* */
 
$tmpl->add_var("portalpage", "BANNER", $banner);
 
?>
The string assignment in this example creates the variable $banner. Then $banner is given the static text values of Welcome and , the current date is. Dynamic data, the user’s name, is assigned calling the variable $tmpl->USERINFO['USER']. The current date is also dynamically generated by using the PHP function date() and formatting the date as month F, day j and year Y:
$banner = "Welcome " . $tmpl->USERNAME['USER'] . ", the current date is" . date("F j, Y");
2.
With the string $banner now assigned we can call the Xinet Portal function to build our new Variable Data Tag. This is done by calling:
$tmpl->add_var()
.
Usage of $tmpl->add_var():
$tmpl->add_var("WNPortal_Tag_Name",
"VARIABLE_DATA_TAG_NAME", "Variable_Data_Tag_Value"
);
where:
WNPortal_Tag_Name is the name of the Xinet Portal tag that this Variable Data Tag will be assigned, e.g., portalpage.
VARIABLE_DATA_TAG_NAME is the name to assign a Variable Data Tag used in a Xinet Portal template, e.g., PATH. (Please note that all letters must be uppercase!)
Variable_Data_Tag_Value is a string defined in quotes or an assigned variable or a call to another function, e.g., a string such as Hello World, a variable such as $somevariable, or a function such as do_somefunction( ).
So, in our example, we add the following:
$tmpl->add_var("portalpage", "BANNER", $banner);
3.
Let’s now replace the {LANG_VOLHEAD} and {UN} tags with the new Variable Data Tag {BANNER} in the toplevel.tmpl.html template in an Exhibit-style site.