Login   Register  
PHP Classes
elePHPant
Icontem

File: Example

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of djomla  >  URL rewrite  >  Example  >  Download  
File: Example
Role: Example script
Content type: text/plain
Description: example of usage
Class: URL rewrite
Map URLs based on regular expression rules
Author: By
Last change:
Date: 2011-03-02 02:31
Size: 1,002 bytes
 

Contents

Class file image Download
<?php
include ("UrlManager.php");
include (
"Url.php");

$ROUTES['view_articles'] = array(
    
"url" => "/<lang>/article/<title>",
    
"rules" => array(
        
"lang" => "([a-z]{0,2})",
        
"title" => "([a-z0-9\-\_]+)"
    
),
    
"mounts" => array(
        
"controller" => "Frontend_Cms",
        
"action" => "view_article",
        
"exec" => "view_article"
    
)
);

$ROUTES['manager_admin'] = array(
    
"url" => "cms/admin:*",
    
"rules" => array(),
    
"mounts" => array(
        
"controller" => "CmsAdmin",
        
"action" => "init"
    
)
);

$ROUTES['manager_language'] = array(
    
"url" => 'cms/language:*',
    
"rules" => array(),
    
"mounts" => array('controller' => 'CmsLanguage''action' => 'init')
);


foreach  (
$ROUTES as $key => $route) {
    
UrlManager::init()->append_route($key$route);
}

$wanted_url 'cms/language';

$url UrlManager::init()->get_match($wanted_url);

print_r($url);

echo 
"<br>";
echo 
UrlManager::init()->get_route('view_articles')->assemble(array('lang' => 'hr''title' => 'mladenovich''rest' => '?additional_parameter=1'));

?>