Page field update on router

I want to change page title on router.
I tried $page->title = $name;, page is coming but changes didnt work.


c::set('routes', array(
		'method' => 'GET',
		'pattern' => 'custom/(:any)',
		'action'  => function($name) 
			$page = page('custom/states/city');
			$page->title = $name; // Here my change

			$data = array(
				'page' => $page,
				'name' => $name,
				'foo' => "bar"
			return array($page, $data);

The title() method is special and won’t consider that custom value. You could access it in your template via $page->title (note the missing parens), but please note that this is unsupported and may break in the future. It is more stable to access the title from the template data instead.