dburlmanager Dynamic URL rules based on database (provides pretty permalinks or friendly URLs)

  1. DbUrlManager extension.
  2. Documentation
  3. Change Log

DbUrlManager extension.

Provides dynamic database-based URL rules.

Note: As of Yii 1.1.8, this may not be needed anymore. Please refer to custom URL rule classes in the guide.

These dynamic rules are like Wordpress' "pretty permalinks" or "friendly URLs". You do not have to have the controller name (or ID) on the URL: this extension can handle the request URI and route it to the correct controller.

Examples of clean and friendly URLs made possible by this extension:

http://mystore.com/blue-coffe-mug

http://myblog.com/my-first-post

Resources

Documentation

Requirements
  • Yii 1.1.3
Installation
  • Extract the extension directory under protected/extensions
Usage by examples
Setting the extension up (on application configuration file):
'urlManager'=>array(
    'class'=>'ext.DbUrlManager.EDbUrlManager',
    'urlFormat'=>'path',
    'connectionID'=>'db',
    ...
),
Setting up a dynamic rule:
'rules'=>array(
    // A dynamic rule.
    '<author:[\w-]+>/<post:[\w-]+>'=>array(
        'post/view',
        'type'=>'db',
        'fields'=>array(
            'author'=>array(
                'table'=>'tbl_author',
                'field'=>'author_name'
            ),
            'post'=>array(
                'table'=>'tbl_post',
                'field'=>'post_slug'
            ),
        ),
    ),
    // Now additional standard rules.
    '<controller:\w+>/<id:\d+>'=>'<controller>/view',
    '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
    '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),

For further instructions, look at the comment blocks in the beginning of the class file.

Change Log

August 31, 2010
  • Initial release: 1.0.
7 0
15 followers
1 547 downloads
Yii Version: 1.1
License: MIT
Category: Others
Tags:
Developed by: Rodrigo Coelho
Created on: Aug 31, 2010
Last updated: 6 years ago

Downloads

show all