|
Articles -
Mambo
|
|
Page 4 of 4
Date functions
To display current date, use mosCurrentDate() function. This function has one input argument which is the date format. If none specified, it will use the default format '_DATE_FORMAT_LC' which is set in your language file (by default it is language/english.php). The returned date is also offset according to your setting in Global Configuration ('Locale' tab, 'Time Offset' option).
<?php
echo mosCurrentDate();
?>
To display date other than the current date, there is a function called mosFormatDate() which accepts 3 arguments: the date, format (optional), and offset value (optional). If format is not set, again '_DATE_FORMAT_LC' will be used. If offset is not set, the value in Global Configuration will be used. The input date should have the format of 'yyyy-mm-dd hh:mm:ss'.
<?php
echo mosFormatDate('2005-01-01 10:00:00');
?>
Both functions are defined in installdir/includes/mambo.php.
Other functions and variables
mosGetBrowser($agent)
Input of this function is the user-agent string (can be obtained from $_SERVER['HTTP_USER_AGENT'] variable) and the output is the user-friendly name and version of the browser. The browser list used to match against the user-agent can be found in installdir/includes/agent_browser.php.
Usage example:
<?php
echo 'You are using '.
mosGetBrowser($_SERVER['HTTP_USER_AGENT']).
' to browser this site';
?>
mosGetOS($agent)
Input of this function is also user-agent string and the output is the user-friendly name of user's operating system. The operating system list used to match against the user-agent can be found in installdir/includes/agent_os.php.
Usage example:
<?php
echo 'Your operating system is '.
mosGetOS($_SERVER['HTTP_USER_AGENT']);
?>
$mosConfig_sitename
This variable contains your site name as defined in 'Site Name' field in Global Configuration page.
Usage example:
<?php
echo "Welcome to $mosConfig_sitename!";
?>
$mosConfig_absolute_path
This variable contains the absolute path to your Mambo installation directory.
Usage example:
<?php
$footer = $mosConfig_absolute_path.'includes/footer.php';
include_once($footer);
?>
$mosConfig_live_site
This variable contains the URL of $mosConfig_absolute_path.
Usage example:
<?php
echo '<img src="' . $mosConfig_live_site .
'/templates/mytemplate/images/logo.gif">';
?>
|