symphonists / url_router Goto Github PK
View Code? Open in Web Editor NEWAn URL Router extension for Symphony
License: Other
An URL Router extension for Symphony
License: Other
When creating new routes, the help text for simplified notations displays like this:
Simplified: page-name/$user/projects/$project
After saving it looks like this:
Simplified: page-name/:user/projects/:project
Only one can be right. Which?
I would like to table a debate about the syntax of the simplified url routing that @alpacaaa kindly added. I am leaning towards this now for general use, and it should be definitely pushed as the primary routing technique over the more 'advanced' regex.
I feel personally that as primarily XSL developers, who are used to parameter syntax like $param
, it can be confusing to use syntax from Rails like :param
.
Any thoughts? @nils-werner @alpacaaa ?
Hello Symphonists,
I get an error when I try to save my route definitions.
First route: "Force re-route if page exists" is checked
Second route: "Force re-route if page exists" is not checked
The generated query:
INSERT INTO
`sym_url_router` (`type`, `from`, `to`, `http301`)
VALUES
('route', '/\/foo\/(.+\/)/', '/foo/$1', 'yes'),
('route', '/\/foo\/(.+\/)/', '/foo/$1')
Error message:
Error : Column count doesn't match value count at row 2
(MySQL version is 5.1.32)
Copied from Symphony CMS Forum:
It might be messed up permissions on my particular Symphony 2.3 installation here, but I can’t for the life of me get this extension (2.0.1, though readme says 1.3) working. I tried on two different 2.3 installations, the activation works fine, but I get no options in my preferences and no other options in any navgroups either. Am I missing something very obvious again? :)
Very good extension, just having some problems with regexp.
Would be very cool if you could define routes as rails does. Something like this:
user/:name/comments => user/comments/:name
user/:name/comments/:comment-id => user/comments/:name/:comment-id
Of course regexp are a lot more flexible, but I think this is a very good solution for those who don't need that level of control.
Don't know how difficult is implementing this idea, but would be very cool ;)
I have consistently used this route to shortcut URLs such as:
example.com/page/about/
to
example.com/about/
The page "page" accepts the parameter "$page". This works with Sym 2.3.x and URL Router 2.0.2.
On Sym versions 2.4 and 2.5.1 and URL Router 3.0 this no longer seems to work. Is there anything which has changed on either release which would cause this to fail? Thanks
I don't see any errors, I am simple sent to the index
page rather than the page
page. Its as if Debug data looks like this:
<root-page>home</root-page>
<current-page>home</current-page>
<current-page-id>1</current-page-id>
<current-path>/who-we-are</current-path>
The index page isn't setup to accept URL parameters. If I disable the extension I then get a 404.
Nothing is included in the logs.
I'm happy to provide sum login details if anyone would be happy to have a look.
Using Symphony 2.2.3 and URL_Router 1.2.
I've added a Route and a Redirect. Redirects consistently throw a browser error "310 Too many redirects". Changing the same regEx etc. to a 'Route' works fine.
I created a Page called page
and set up the following routes...
From /:pt1
To /page/:pt1
and
From /:pt1/:pt2
To /page/:pt1/:pt2
I also, setup a page called menu
and the page is ignored since I have the above route setup...
So then I add in the following route...
From /menu/
To /menu/
And nothing happens, it still uses the Page called page
instead of menu
How I am able to use another page?
The help text for the new rails style routing is switched around - making this extension pretty confusing for newcomers. See thread: http://symphony-cms.com/discuss/thread/37320/4/#position-64
When doing it's wonderful thang of routing anything that doesn't match a 'page' to the root page's params, 404 pages are broken.
Is there any way we can check the root pages params and redirect to 404 if they don't exist? Should this be something that is done in the main datasource for the root page, using it's 404 method? Should we therefore be telling people to make sure they do this?
Thoughts from @Alpacaa @tonyarnold and @nils-werner appreciated.
Symphony Warning: preg_match(): Unknown modifier 'h'
An error occurred in D:\wamp\www\pb\extensions\url_router\extension.driver.php around line 102
97
98 $return = array();
99
100 foreach($routes as $route)
101 {
102 if(preg_match($route['from'], $path, $matches) == 1)
103 {
104 $route['routed'] = preg_replace($route['from'], $route['to'], $path);
105
106 $route['original'] = $path;
Need to add ability to append messages on save to Notify plugin.
When setting multiple routes, only the first route works as expected. All other routes are ignored.
I tracked down the problem to the break
function. The break
should end the loop only if a match is found. So, just move the break
inside the if statement group.
foreach($routes as $route)
{
if(preg_match($route['from'], $path, $matches) == 1)
{
$route['routed'] = preg_replace($route['from'], $route['to'], $path);
$route['original'] = $path;
$return = $route;
break;
}
}
I'd like to redirect from a page team
to a page anmeldung
as soon as team
doesn't have any additional URL parameters set. I got the router to match the needed from
path using /team?\/$/
but I'm running into a problem with the redirection: it doesn't redirect based on Symphony's document root but based on the server root (I tried either anmeldung
or /anmeldung/
without success). So when my from
URL is http://localhost/example.com/team/
I get redirected to http://localhost/anmeldung/
– but I'd like to end at http://localhost/example.com/anmeldung/
.
I'd expect this extension to always redirect based on Symphony's document root and not the server root.
(Symphony 2.2.5 and Url Router 1.2)
As described on the Forum
The URL Router adds a trailing slash ("/") to a route when there's no trailing slash in the To-URL.
Example: I redirect /\/abonneer/
to http://foo.bar.list-manage.com/subscribe?u=123abc
(note the querystring and lack of trailing slash)
My destination url becomes http://foo.bar.list-manage.com/subscribe?u=123abc/ and fails on the trailing slash ("Too many redirects" error).
The slash seems always added in extension.driver.php:123 which (in my case) is unwanted since there's a querystring.
Local installation, Symphony 2.2.5, URL Router 1.3
Server document root: http://localhost:8080/
Website document root: http://localhost:8080/website
Goal: Redirect from site's index page to the same page with an added required default parameter (data source attached to page filtering entries on required parameter).
Redirect rule: from: ^$^ to: /default-parameter/
Accessing http://localhost:8080/website/
redirects to http://localhost:8080/default-parameter/
, instead of http://localhost:8080/website/default-parameter/
.
Accessing http://localhost:8080/website/parameter-that-should-throw-404/
redirects to http://localhost:8080/parameter-that-should-throw-404//default-parameter/
, instead of throwing an 404 error since no entries are returned by the data source.
Hmm, this looks odd ...
Why are there 2 queries performed on installation?
The page I am trying to route exists and without the check box 'force re-route even if page exists' it doesn't seem to work for me. Am I doing something wrong?
I have two pages;
projects (shows a list of projects)
projects/projects-single (shows project detail and accepts the $project-title url parameter)
Currently the route for the individual project is
from
//projects/(.+)//
to
/projects/projects-single/$1/
this works with older versions of the router but not 3.1 - if any one can point me in the right direction I would be grateful.
Many thanks
Since we are trying to move from .htaccess
to php
routing, it would be very convenient if this extension was also usable for routes to static assets like JS and CSS files.
For instance, it is bad practice to request your styles with a querystring: style.css?v=204
, incorporating it into the name is better: style-204.css
. This is because some caching proxies will not cache the file when there is a query parameter present.
However, to do so a route is needed (a redirect will not work, as then the destination will still be cached), but at this moment routes only work for Symphony pages - not for files in the filesystem. Leaving me with no other option than to add the route to the server config - which is something I really, really want to stop doing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.