This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi,
I'm working on my first October CMS project. I have some experience with lavarel, but some things are not clean in october.
In the documentation there is: "CMS pages define their own URL routes in their page configuration". Is there an easy way to override that? My problem is that I want to define the URL like: url = "term/slug:slug", where last "slug" should be param, but it only works if I put a slash before it like: url = "term/slug/:slug". Is there an easy way to get rid of the "/"? (I re-writing an old site and would like to keep old link structure as much as possible.)
If I add routes.php (
Route::get('/nodes/term/slug:{slug?}', function ($slug) { return $slug; });
) to the plugin it works, but I guess there must be an easier way.
If it can be done only using the routes.php, how can I return the CMS page from there?
Thank you!
Last updated
I see two ways to do that within a CMS page :
- url = "term/:slug|^slug.+$" (and parse the slug in onInit())
- add a rewrite rule in apache to redirect old route scheme to /term/slug/:slug
mjauvin said:
I see two ways to do that within a CMS page :
- url = "term/:slug|^slug.+$" (and parse the slug in onInit())
- add a rewrite rule in apache to redirect old route scheme to /term/slug/:slug
Thank you for the answer, but I don't undertstand. What want to have is: Route::get('/term/slug:{slug?}'. Like: "/term/slug:someslug", without the "/" before ":"
Last updated
mjauvin said:
I see two ways to do that within a CMS page :
- url = "term/:slug|^slug.+$" (and parse the slug in onInit())
- add a rewrite rule in apache to redirect old route scheme to /term/slug/:slug
Thanks again.
It worked with 1. "term/slug:someslug" returns: "slug" => "slug:someslug" Not exactly what I need, but I can make it work.
"|^slug.+$" - isn't supposed to remove 'slug' from "slug:someslug"?
Last updated
It worked with 1. "term/slug:someslug" returns: "slug" => "slug:someslug" Not exactly what I need, but I can make it work.
"|^slug.+$" - isn't supposed to remove 'slug' from "slug:someslug"?
No, just to ensure the slug ACTUALLY starts with "slug"... you still need to parse the actual slug out of that, but it's fairly easy...
$slug = substr($this->param('slug'), 4);
title = my test page
url = "term/:slug|^slug.+$"
==
function onInit()
{
$this['slug'] = substr($this->param('slug'), 4);
}
==
This is the slug: {{ slug }}
No problem. But I agree, it would be nice if you could have the same URL syntax as in Laravel / routes.
1-8 of 8