• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.