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 have a page with following configuration
title = "Page title"
url = "/mypage/:someId/:someComponentConfig"
layout = "default"
is_hidden = 0
[myComponent]
id = {{ :someComponentConfig }}
I need to make the layout dependent from the :someId
parameter, for instance id = 1 => a_layout, id = 2 => other_layout.
Is there a way to do that? I have tried with cms.router.beforeRoute event and generating a page similar as how it is done in static pages but the page is not rendered, only the layout.
Thank you!
Last updated
Well, it seems dynamic layouts are not needed for my use case. I created files layout-1 and layout-2 and two pages page-1 and page-2.
And did something like this: page-1.htm
title = "Page title"
url = "/mypage/1/:someComponentConfig"
layout = "layout-1"
is_hidden = 0
[myComponent]
id = {{ :someComponentConfig }}
and for the other one: page-2.htm
title = "Page title"
url = "/mypage/2/:someComponentConfig"
layout = "layout-2"
is_hidden = 0
[myComponent]
id = {{ :someComponentConfig }}
Then I just have the layout based in the url parameter. I have to duplicate the pages but that won't kill me :)
1-2 of 2