Making Links

By orqi

As we know, a typical Orqi url will look something like this with mod_rewrite enabled ..
http://telephotos.co.uk/photo/latest.html

… or like this with mod_rewrite disabled
http://telephotos.co.uk/index.php?object=photo&action=latest

Now, there is an easy way to generate these links in your Orqi templates in a way that will still create the right url for you even if your mod_rewrite is set to false in the config.

Controller::MakeLink

Here is the declaration of the the Makelink function. As per the usual Orqi request, you are nominating a controller, then a function/action to execute. The parameters field is for the inevitable extra stuff you will need to pass.

function MakeLink($object='', $action='', $params='', $secure=false)

Examples

Taking the telephotos site as an example. Here are some usages. The application location value in the config in telephotos is set as follows.

$this->app['location'] = "http://telephotos.co.uk";

Examples of usage with mod_rewrite enabled

// will produce http://telephotos.co.uk/photo/latest.html
$this->MakeLink('photo', 'latest');

// will produce http://telephotos.co.uk/photo/view.html?id=935
$this->MakeLink('photo', 'view', 'id=935');

Examples of usage with mod_rewrite disabled

// will produce http://telephotos.co.uk/index.php?object=photo&action=latest
$this->MakeLink('photo', 'latest');

// will produce http://telephotos.co.uk/index.php?object=photo&action=view&id=935
$this->MakeLink('photo', 'view', 'id=935');

Note: When you are passing values into the $params parameter you do not need a leading ampersand (& ) or question mark, but if you are passing more than one value then you will need to separate them will ampersands.

$this->MakeLink('photo', 'view', 'id=935&anothervalue=blah');

Tags: , ,

Leave a Reply