LoadTemplate
/* @param String $template_name @param Boolean $sendtoscreen @return HTML||false */ function LoadTemplate($template_name='', $sendtoscreen=true)
Takes in a file name and includes the file. First it looks for the file in the project _UI folder. If it can’t find a file it will look in Orqi’s _UI folder. If it still hasn’t found a file it will try using the file name as on absolute link and if that fails then it outputs an error message.
The $sendtoscreen parameter is set to TRUE by default. This means when the template is included the HTML in it will start being written to the screen. When $sendtoscreen is set to FALSE, the incoming template is saved as a string and returned to the caller. This is useful for sending emails and having email templates setup in the _UI folder.
LoadComponent
/* @param String $component_name @param Object $param1 @param Object $param2 @param Object $param3 @param Object $param4 */ function LoadComponent($component_name='', $param1='', $param2='', $param3='', $param4='')
Just like the LoadTemplate() function, this checks for components in the _UI folders of the project, then Orqi, finally trying the $component_name as an absolute URL before printing out an error.
In some templates I’ve used local variables (largely because of the limitations of PHP4) and to allow the component to access these variables, the LoadComponent() function can be passed them in the $param1-4 spaces.
NB: $sendtoscreen is not needed here as LoadComponent() inherits that behaviour
NB: Component file names all begin with an underscore.
Redirect
/* @param ValidURL $goto */ function Redirect($goto='')
This will forward to a specified URL. If you don’t specify a URL then it will return you to the referer.
NB: Use $this->MakeLink() to create Orqi-friendly URLs
NB: If the redirect sends you to a blank screen, you can view the HTML source to find out which file has output some content to the write buffer.
GoToPage
/* @param ValidURL $url @param Integer $page_number @param String $varname @return ValidURL */ function GoToPage($url, $page_number, $varname='')
This takes in an Orqi URL and replaces the page parameter value with the specified value. If you are showing multiple lists on one page, you can specify a variable name in $varname so that Orqi remembers what page number you are on with the other lists when you click next or previous on a particular list.
MakeLink
/* @param String $object @param String $action @param String $params @return ValidURL */ function MakeLink($object='', $action='', $params='', $secure=false)
This takes in strings and converts them into a valid Orqi URL based on the configuration settings.
object: is the name of a controller. (controller is added to the name when the Loader tries looking for the controller.
action: is the name of the controller’s function.
params: is basically the extra info needed like ?id=X&page=Y
SetPagingVars
/* @param Integer $total_rows */ function SetPagingVars($total_rows='', $varname='')
This is usually called on a list page that displays a paging bar. This function will create an associative array of values that contain all the necessary values to work out the links for the paging bar.
$this->page['items']: // total number of items $this->page['first']: // the number of the first page $this->page['last']: // the number of the last page $this->page['prev']: // the number of the previous page $this->page['next']: // the number of the next page $this->page['current']: // the current page number $this->page['start']: // the first row to select in the SQL statement, ie LIMIT start, end $this->page['end']: // the last row to select in the SQL statement, ie LIMIT start, end
Tags: Classes, controller