This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

twensons63456
twensons63456

Hello! I'am try to change my articles urls Now its: /posts/:slug (/posts/test-article)

But i want urls like that: /posts/:slug.html (/posts/test-article.html)

But when i change on admin - pages -> blog post -> url to that /posts/:slug.html it not work. How to be?

mjauvin
mjauvin

Now why would you want to do that?

mjauvin
mjauvin

If you really need to do this, here's how:

title = my test post page
url = "/posts/:slug"
layout = default
==
function onInit()
{  
   $slug = str_replace('.html', '', $this->param('slug'));
   $this->addComponent('blogPost', null, ['slug' => $slug]);
}
==
<h1>{{ post.title }}</h1>
{{ post.content|md }}
twensons63456
twensons63456

I added like that - https://pastebin.com/2sJTALxk But i get: post) { $this->page->title = $this->post->title; } else { return Redirect::to($this->pageUrl('404')); } } ?>

Last updated

mjauvin
mjauvin

You need to remove the blogPost component from the config section

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.