Gallery 3 uses Kohana's routing system to connect a url to a controller. There is a simple mapping between the URL that you see in the address bar of your browser and the function name in a controller that's executed.
For this URL:
http://example.com/gallery3/index.php/tag/add/3/foo ^ ^ ^ ^ ^ ^ │ │ │ │ │ ├── function arguments │ │ │ │ ├── function named "add" │ │ │ ├── controller "Tag_Controller" │ │ ├── main Gallery 3 PHP script, edit │ │ gallery3/.htaccess to remove this │ ├── directory where Gallery 3 is installed ├── hostname of your website
Gallery 3 expects that there will be a controller called Tag_Controller containing a function named add. This controller can be in any module, if there are two controllers with the same name the module load order will break the tie. Anything data after the function name will be passed to the function as arguments. In the above example, you might have the following code:
modules/example/controllers/tag.php
<? class Tag_Controller extends Controller { public function add($item_id, $tag_name) { // $item_id == 3 // $tag_name == "foo" } }
When generating Galley 3 URLs, use the url::site() function from the Kohana URL helper to refer to a controller and function. For example to generate the url above, you would do:
<?= url::site("tag/add/3/foo") ?> <?= url::site("tag/add/3/foo?q=1") // query params are ok ?> <?= url::site("items/{$item->id}") // variables are fine ?>
Gallery 3 extends the URL helper in modules/gallery/helpers/MY_url.php to add the following additional methods: