miniCal
  • Quick Start
    • Introduction
  • miniCal Configuration
    • miniCal Hosted Service
    • Configure Feature Settings
    • Install Extensions
    • Create Multiple Properties
  • Local Installation
    • Local Installation
    • ENV Set-Up
    • Configuration Settings
    • Common Installations Errors
  • Contribution
    • Contribute to miniCal Core
  • Build an Extension
    • Build Your First Extension
      • Controllers
      • Assets
      • Config
      • language
      • Models
      • View
      • Helper
      • Library
      • Hooks
    • Open-source Extensions
    • Config Folder Files
      • Autoload File
      • Config File
      • Route File
    • miniCal Filters
    • miniCal Actions
    • Create Custom Hooks
    • Store Custom Data
      • POSTS
      • POSTMETA
      • OPTIONS
    • Composer Dependencies
  • Marketplace
    • miniCal Marketplace
  • Other resources
    • Overbooking for OTAs
    • miniCal Cron Setup
    • Automated Night Audit
    • Nginx Configuration
    • Docker Installation
    • Custom Domain Setup
  • Minical API Docs
    • API Documentation
  • Coming soon!
    • Access minical Data Using Helpers
      • Company Helper Functions
      • Customer Helper Functions
      • Booking Helper Functions
      • Rates Helper Functions
      • Rate Plan Helper Functions
      • Availability Helper Functions
      • Statement Helper Functions
      • Tax Helper Functions
      • Room Helper Functions
      • Charge Helper Functions
      • Payment Helper Functions
    • Access data in Extension
Powered by GitBook
On this page
  • How to define the route for the extensions
  • How to pass parameters in route
  1. Build an Extension
  2. Config Folder Files

Route File

PreviousConfig FileNextminiCal Filters

Last updated 3 years ago

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/Method/Parameter/
  • 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.

$extension_route['list'] = 'show_booking/show_latest_bookings';

Use the $extension_route variable for routes, it's the same as CI routes.

$extension_route['list'] 

Here this list is the route name, the URL for this route will look like this "" 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:

//Syntaxt
$extension_route['route_name/:num'] = 'contoller/method/$1';
//example
$extension_route['product/:num'] = 'catalog/product_lookup/$1';

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

$extension_route['route_one'] = 'controller/method';
$extension_route['route_two/(:any)'] = 'controller/method/$1';
$extension_route['route_three/(:any)/(:any)'] = 'controller/method/$1/$2';
$extension_route['route_four/(:any)/(:any)/(:any)'] = 'controller/method/$1/$2/3';

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

https://demo.minical.io/list