This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hey there,
I'm relatively new to October so maybe this is an easy one for you:
What I need is a page with a wildcard URL, e.g. http://example.com/magazine/*
where *
can be anything, also "something/something/something"
So the page should be visible no matter what URL parameters are set after "/magazine/"
I tried to use an URL like this: /magazine/:param?
according to https://octobercms.com/docs/cms/pages#configuration
This works for URLs like /magazine/something
(param
= "something") but not /magazine/something/something
(param
should be "something/something") and this is what I need to figure out. I need param
to store the string after /magazine/
no matter what it is and no matter how my URL parameters there are. Is there a way?
Thanks, Christian
Last updated
I figured if you know the maximum number of URL parameters you can do something like this for the page URL:
/magazine/:param1?/:param2?/:param3?
however, this doesn't solve the problem with an unknown number of parameters.
I don't think you can specify a wildcard value for an unknown number of params. You could either just pass a large number of optional params as per your answer above e.g. or you can use a different separator and then split them in the code:
/magazine/article-44-john smith-another param
url="/magazine/:params"
==
function onStart()
{
$this['params'] = explode("-", $this->param('params'));
}
==
{% for p in params %}
<li> {{ p }} </li>
{% endfor %}
Last updated
1-4 of 4