Access URL parameters in a cms page or partial
10
There are multiple ways to access URL parameters in a cms page or partial. This trick shows you how you can access the different parts of an example URL http://example.com/detail/a-custom-model-slug?page=1
.
url = "/detail/:slug"
==
function onStart()
{
// The following URL is given
// http://example.com/detail/a-custom-model-slug?page=1
$this['pageNum'] = request()->get('page');
// or
// $this['pageNum'] = \Request::get('page');
$this['slug'] = $this->param('slug');
}
==
Slug is {{ slug }}, page is {{ pageNum }}.
There are no comments yet
Be the first one to comment