cpanel tag. As noted above, these cpanel tags print data to the cPanel interface. cpanel tags use the following format:
In the example above:<cpanel Module="function( params )">
Module — Represents the module that holds the function you wish to use. Mysql::
function — Represents the API function you wish to use. adddb
params — Represents any parameters you wish to pass the function. dbname
<cpanel Mysql="adddb(dbname)">
Mysql::adddb is a good example of a function whose output you would generally want to prevent from printing to the interface, for security reasons.
In order to prevent data from being printed to the cPanel interface, enclose the function in the tag like so:
<!--Module="function()"-->
$FORM and $CPERROR variables and the cpanelif tag.
$FORM is a variable that is populated with GET or POST data passed from the browser to the page. This variable is used by cPanel to transfer important information from page to page. Accessing the information within the variable is done the same way that one could call a hash in Perl.
($FORM{'element'})
As an example, you could have a page called add_mysql-db that would be passed the following information:
cpanel tag, you can also use the cpanelif tag. This tag allows you to utilize some very basic logic within the system. The cpanelif tag allows you to check basic boolean logic to see whether a variable is set. If the check returns true, then whatever is contained between the <cpanelif> tags to the browser.
<cpanelif> tags however you can use the || and && operators to perform multiple checks.
To use the cpanelif tag:
<cpanelif $VAR{''}>
HTML CODE HERE
</cpanelif>
This can be useful when you want to display an error message in the cPanel interface. Error messages are populated into the $CPERROR variable like so:
$CPERROR{$context}
The $context area of this variable is defined on the back-end of cPanel on a per-module basis. Generally, $context will be whatever module you are using.
If, continuing from the example above, you wanted to check for an error message, you would need to use the a code block similar to the following:
<cpanel Mysql="adddb( $FORM{'db'} )">
<cpanelif $CPERROR{'mysql'}>
ERROR: <cpanel print="$CPERROR{'mysql'}">
</cpanelif>
In the current system, success messages are also populated into the $CPERROR variable. In successful cases, you will want to ignore this variable using the following method:
!$CPERROR{'mysql'}
These tags can also be used with an exclamation point to display a message if a feature is not available:<cpanelfeature mysql> <a href="sql/index.html">Manage MySQL</a> </cpanelfeature>
<cpanelfeature !mysql> We see that you do not have MySQL enabled for your account. Click here to order an upgrade. </cpanelfeature>
Copyright © cPanel 2000-2009.