3.1.3 - Router slug

New Feature : Router slug

Your component is now able to re-use the alias (From the alias Wizard) for creating beautiful URLs.
It works also for Foreign Key filters.
The following examples are available in the sample component (Hello My World)

Slug

Here an example with slug :
index.php/component/hellomyworld/city/city/9-canberra

or :
index.php/component/hellomyworld/city/city/canberra

Filters

Example with continent filter:
index.php/component/hellomyworld/cities/cities/europe

Example with country filter (in second position):
index.php/component/hellomyworld/cities/cities/-/france

Example with continent + country filter:
index.php/component/hellomyworld/cities/cities/europe/france

Configuration

To custom the router, simply refers to the bottom of the router.php file, in the XxxxRouteConfig()
The first index is always the view name.
Then, every sub entry represent the order of the segments.

array(

// CITY (ITEM)

    // First segment : VIEW name
    'city' => array(

        // Second segment : LAYOUT name
        array(
            'type' => 'layout'
        ),

        // Third segment : SLUG
        array(
            'type' => 'slug',
            'aliasKey' => 'alias'   // The router must know the alias field to search on
        )
    ),

// CITIES (LIST)

    // First segment : VIEW name
    'cities' => array(

        // Second segment : LAYOUT name
        array(
            'type' => 'layout'
        ),

        // Third segment : FILTER (continent)
        array(
            'type' => 'filter',
            'name' => 'country_continent',  // Filter name
            'model' => 'continent',         // Must know the name of the model to search on
            'aliasKey' => 'alias'           // If the related model has a slug, you can define this alias key (it will automatically instance a slug)
        ),

        // Fourth segment : FILTER (country)
        array(
            'type' => 'filter',             
            'name' => 'country',            // Filter name
            'model' => 'country',           // Must know the name of the model to search on
            'aliasKey' => 'alias'           // If the related model has a slug, you can define this alias key (it will automatically instance a slug)
        ),

        // Fifth segment : FILTER (travellers)
        array(
            'type' => 'filter',             
            'name' => 'travellers',         // Filter name
            // 'model' => 'traveller'       // Model is not required if there is no slug
        )
    ),

// TRAVELER

    // First segment : VIEW name
    'traveller' => array(

        // Second segment : LAYOUT name
        array(
            'type' => 'layout'
        ),

        // Third segment : Primary key (cid)
        array(
            'type' => 'var',    // In this case, the primary key is NOT handled by slug (no alias wizard for this table)
            'name' => 'cid'     // Will simply put an integer value in the segment
        )
    ),
);

This configuration is shared between parseRoute() and buildRoute()
You can try to change the order of the segments to see how your component manage easily the route.

Freakin' Awesome!!! J-Cook is simply awesome - whether you're a highly experienced developer or complete novice whether you're building a small inventory component or a complete community solution! The beauty comes from a fast slick and reliable platform that readily provides developers with everything they'll need to build the backbone of a solid and secure component with wizards for authoring access publishing aliasing created/modified by dates... you name it COOK provides it! J-Cook really surpasses all of the 'competition' as far as MVC tools are concerned! Try love it and get cooking!
learnthrusong (JED)
          

Get Started