Welcome Guest, Not a member yet? Register   Sign In
URI Routing problem
#1

[eluser]mo2men[/eluser]
hi

i use this in my controller 'site'
and 2 functions
index
page
Code:
class review extends Controller{

   function _remap($method)
   {
      if(method_exists($this,$method))
      {
        $this->$method();
      }

      else
      {
        $this->index();

      }
      


   }

   function  __construct() {
       parent::Controller();
        $this->load->model('review_model');
        $this->load->library('form_validation');
        $this->load->library('pagination');
    }

    function index($offset='')
    {
       $url = $this->uri->segment(2);
       $data['url'] = $url;


        $data['user_id']    = $this->tank_auth->get_user_id();
    $data['username']    = $this->tank_auth->get_username();
        
       $query = $this->review_model->exist_review($url);
               if($query == FALSE){
                   echo "no";
               }


               else{
                // my code //

               }
    }




     function page($page,$offset=''){
         // my code //
    }

  

    
}
?>

and this in my routes
Code:
$routes['review/:any'] = "review/index/$1";


problem is when i go to function page
localhost/site/review/page/444

show error
how can i fix it
#2

[eluser]Cristian Gilè[/eluser]
What is the error message?

If you call localhost/site/review/page/444 _remap function check for the exixtence of page method and call it, but the page method requires two parameters and one of which (page) is mandatory.

Cristian Gilè
#3

[eluser]mo2men[/eluser]
show this message

A PHP Error was encountered

Severity: Warning

Message: Missing argument 1 for review::page(), called in C:\AppServ\www\gp2me\application\controllers\review.php on line 8 and defined

Filename: controllers/review.php

Line Number: 70
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: page

Filename: controllers/review.php

Line Number: 73
#4

[eluser]Ochetski[/eluser]
Your function have 2 arguments, the second is optional with default '' but the first must appear when you call review::page(), even if it's null review::page(false) or review::page(null) should work.


Or you can add a default for first parameter:

function page($page=false,$offset=''){
// my code //
}




Theme © iAndrew 2016 - Forum software by © MyBB