October CMS resources and help articles

Simple and to the point. Optimized by the community.

Access URL parameters in a cms page or partial

10
by OFFLINE, last modified on August 12th, 2019

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 }}.

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?