Route File
Routes are responsible for responding to URL requests. Routing matches the URL to the pre-defined routes. Routes in miniCal are defined using the below example:
Controller -is mapped to the controller name that should respond to the URL.
Method – is mapped to the method in the controller that should respond to the URI request.
Parameter – this section is optional.
How to define the route for the extensions
For defining route for extension go to the route.php filer under the config folder of your extension. Here is an example for the route file.
Use the $extension_route variable for routes, it's the same as CI routes.
Here this list is the route name, the URL for this route will look like this "https://demo.minical.io/list" Now, this route is bound with a controller and its method. In the above example, we can see that this list route is bound with show_booking controller and the method of show_booking controller is "show_latest_bookings".
How to pass parameters in route
A typical route with a might look something like this:
In a route, the array key contains the URI to be matched, while the array value contains the destination it should be re-routed to. In the above example, if the literal word “product” is found in the first segment of the URL, and a number is found in the second segment, the “catalog” class and the “product_lookup” method are instead used. (:num) will match a segment containing only numbers. (:any) will match a segment containing any character (except for ‘/’, which is the segment delimiter).
You can send n-numbers of parameters with a route
Here we have provided the list of basic URLs (CRUD operations)
Syntaxt | URL | Route | Controller | Method |
---|---|---|---|---|
$extension_route['/booking_list'] = 'bookinng_controller/index'; | /booking_list | $extension_route['/booking_list'] | bookinng_controller | index |
$extension_route['/booking/create'] = 'bookinng_controller/create'; | /booking/create | $extension_route['/booking/create'] | bookinng_controller | create |
$extension_route['/booking/edit/:id'] = 'bookinng_controller/edit'; | /booking/edit/id | $extension_route['/booking/edit/:id'] | bookinng_controller | edit |
$extension_route['/booking/delete/:id'] = 'bookinng_controller/delete'; | /booking/delete/id | $extension_route['/booking/delete/:id'] | bookinng_controller | delete |
Last updated