Welcome Guest, Not a member yet? Register   Sign In
Static Route / predefined variables
#1

I am trying to setup a route that sets a fixed parameter

PHP Code:
$routes->get('/''Pages::showme/first');
$routes->get('pages/showme/(:alphanum)''Pages::showme/$1'); 

hitting "/" results in

Code:
Controller method is not found: showme\first

But "/pages/showme/first" works as expected

I have read the route manual but have not found a way to do it, any help is greatly appreciated
Reply
#2

Route code
PHP Code:
$routes->get('/''Pages::showme'); 

Controller method code
PHP Code:
public function showme($param 'first'


Default parameter value is ok,  Big Grin
Reply
#3

Thanks for your reply! That works as expected with a small caveat

Code:
/pages/showme/

is now accessible instead of throwing an error

My controller looks something like this, ie. i don't want to have a default value

PHP Code:
public function showme($param '') {
 
   if($param == ''){show_404();}
.
.

Reply




Theme © iAndrew 2016 - Forum software by © MyBB