Custom lithium routing scenario

Asked
Active3 hr before
Viewed126 times

4 Answers

routingcustom
90%

If you don't have any convention in the URL for what is what, between page, item and category. I'd go with a very generic router.,And in Pages::any() to search for the correct stuff. Is that category a page after all (example 4)? Is that page an item (example 1)?, @EricC the crucial keys parameter was missing, it does the matching between the regexp and the Request::$params your controller receives. – greut Jan 4 '12 at 16:29 , Podcast 394: what if you could invest in your favorite developer?

If you don't have any convention in the URL for what is what, between page, item and category. I'd go with a very generic router.

Router::connect('/{:category}/{:page}/{:item}', 'Pages::any');
Router::connect('/{:category}/{:page}', array('Pages::any', 'item' => null));
Router::connect('/{:category}', array('Pages::any', 'page' => null, 'item' => null));
load more v
88%

I'm trying to create a very simple URL routing, and my thought process was this:,I just thought of routing my URLs which is like #code# and it would be pretty nice if it was #code# Where should I start when routing URLs in my web application...,The static URLs are easy to do of course, but I'm trying to figure out the best way to do dynamic ones. I would prefer not to have to set a static prefix, despite knowing that it would make this a lot easier to code.,I am putting together a simple networking site and would like to have the urls work similar to facebook so by typing in domain.com/username I would get a user p...

This is what I currently have:

$requestURL = $_SERVER['REQUEST_URI'];

if ($requestURL == '/') {
   // do stuff for the homepage
}

elseif($requestURL == '/register') {
   // do stuff for registration
}

// should match just "/some-unique-url-here"
elseif(preg_match("/([/A-Za-z0-9-]+)/", $requestURL)) {
   // query database for that url variable
}

// should match "/some-unique-url/and-another-unique-url"
elseif(preg_match("(^/[A-Za-z0-9-]+/[A-Za-z0-9-]+)/", $requestURL)) {
   // query database for first and second variable
}

else {
   // 404 stuff
}
load more v
72%

Nice example! Is it possible to make admin routes to be handled by separate controllers under a app\controllers\admin namespace?,instead of setting action, try setting "controller".

instead of setting action, try setting "controller".

Dispatcher::config(array('rules' => array(
   'admin' => array('controller' => 'admin\{:controller}')
)));
load more v
65%

ODL-3: Extract the tar file of your custom build of Open Daylight Lithium Controller from step ODL-1.,ODL-1: Prerequisite - build Open Daylight Lithium Controller from the the latest stable/Lithium branch, and make it available for step ODL-3.,ODL-3: Extract the tar file,ODL-2: Login to Open Daylight Controller Node with username opnfv.

git clone https: //github.com/sridhargaddam/opnfv_os_ipv6_poc.git /opt/stack/opnfv_os_ipv6_poc
load more v