Skip to content
Snippets Groups Projects
Forked from sucssite / sucs-site
494 commits behind the upstream repository.
Callum Massey's avatar
Callum Massey authored
Added initial version of SU API implementation for freshers fayre, still needs error checking adding, though now ready for testing, improvements welcome.
83d91a6d
History
All components should set the following values

$smarty->assign("title", "Page Title String");
$smarty->assign("body", "output of module");

Optionally,  you can set a right hand side panel
$smarty->assign("secondary", "side boxes");

You can turn on a meta refresh with
$smarty->assign("refresh", value);

Set additional stylesheets to be applied to screen output (strongly discouraged)
$smarty->assign("extra_styles", array('/path/to/additional/stylesheet.css'))

The master script supplies the following php variables:-

$path  		The path of the current selected page
$pathlist  	Broken out version of path in array

$component	The pagemap record used for the current page:
	[id]		Record id
	[path]		path of the root node for this component
	[depth]		path depth
	[component]	component name

$smarty		The smarty object
$DB		The ADODB database object
$session	The Session object

Session has the following properties
$session->loggedin	TRUE if logged in
$session->username	the username
$session->fullname	the users real name
$session->data		array for storing persistant data

any values stored in data[] will be persistant between pages
for as long as the users session cookie stays active.

For error handling, your component should use the trigger_error() function:

trigger_error("Informational message", E_USER_INFO); // To inform the user that something happened, e.g. the session expired
trigger_error("Warning message", E_USER_WARNING); // Warn the user of an expected error, e.g. incorrect password
trigger_error("Error message", E_USER_ERROR); // Reserved for unexpected conditions, e.g. unable to connect to database

You may also use the message_flash("status message") function for helpful messages, e.g. form submitted