Difference between revisions of "Custom Variables"

From AWBS Wiki
Jump to: navigation, search
m (Protected "Custom Variables" [edit=sysop:move=sysop])
 
(9 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
===About===
 
===About===
AWBS is a very customizable system, as you can make your own themes, you can also add your custom data by placing variables and/or php scripts in your template files.
+
AWBS themes are customizable on many fronts.
Sometimes you may need to place the same script or value over and over again in many pages, there comes the value of using custom variables.
+
One extremely powerful customization method you can utilize is adding your custom data by placing variables and/or php scriptlets in your template files.
 +
Sometimes you may need to place the same script or value over and over again in many pages. You can do this using custom variables.
  
Custom variables are stored in a file called '''''gparser_user.php''''', this file can be found in the includes folder in your AWBS root directory ''if you installed AWBS to '''home/user/public_html/''' on your server, gparser_user.php will be found in '''home/user/public_html/includes/gparser_user.php.<font color="red">sample</font>''' - remove the <font color="red">sample</font> fro the file name to so it starts taking effect.''
+
Custom variables are stored in a file called '''''gparser_user.php''''', this file can be found in the includes folder in your AWBS root directory. ''If you installed AWBS to '''home/user/public_html/''' on your server, gparser_user.php will be found in '''home/user/public_html/includes/gparser_user.php.<font color="red">sample</font>''' - remove the <font color="red">sample</font> from the file name to so it starts taking effect.''
 
+
Once you renamed the file, you can start placing your variables and php scripts there.
+
  
 +
Once you renamed the file, you can start placing your variables and php scriptlets there.
  
 
===Format===
 
===Format===
Line 17: Line 17:
  
 
'''Variable Examples'''
 
'''Variable Examples'''
#<pre>$template->set_var("COMPANY_SLOGAN", "Advanced Webhost Billing System");</pre>This example will set a variable COMPANY_SLOGAN, to display it, <pre><?php echo COMPANY_SLOGAN; ?></pre> or <pre><?=COMPANY_SLOGAN?></pre>
+
#<pre>$template->set_var("my_company_name", "Advanced Webhost Billing System");</pre>This example will set a variable $my_company_name. To display it, <pre><?php echo $my_company_name; ?></pre> or <pre><?=$my_company_name?></pre>
#<pre>$template->set_var("$COMPANY_SLOGAN", "Advanced Webhost Billing System");</pre>This example will set a variable COMPANY_SLOGAN, to display it, <pre><?php echo $COMPANY_SLOGAN; ?></pre> or <pre><?=$COMPANY_SLOGAN?></pre>
+
  
 
'''Notes'''
 
'''Notes'''

Latest revision as of 21:51, June 9, 2008

About

AWBS themes are customizable on many fronts. One extremely powerful customization method you can utilize is adding your custom data by placing variables and/or php scriptlets in your template files. Sometimes you may need to place the same script or value over and over again in many pages. You can do this using custom variables.

Custom variables are stored in a file called gparser_user.php, this file can be found in the includes folder in your AWBS root directory. If you installed AWBS to home/user/public_html/ on your server, gparser_user.php will be found in home/user/public_html/includes/gparser_user.php.sample - remove the sample from the file name to so it starts taking effect.

Once you renamed the file, you can start placing your variables and php scriptlets there.

Format

<?php
//Use the following format for additions:

//$template->set_var("template_variable", "your text"); 

?>

Variable Examples

  1. $template->set_var("my_company_name", "Advanced Webhost Billing System");
    This example will set a variable $my_company_name. To display it,
    <?php echo $my_company_name; ?>
    or
    <?=$my_company_name?>

Notes

  1. PHP Scripts, functions, classes, and globals are allowed.
  2. When using a custom function that returns results, make sure to parse the result in a variable
    $template ->set_var("custom_variable", $your_result);
  3. To run MySQL Queries, you need to include dbconfig.php:
    include(WORKDIR."/includes/dbconfig.php");