Welcome Guest, Not a member yet? Register   Sign In
URL parameters and routes - not working
#1

[eluser]Darker[/eluser]
Routes:
Code:
$route['404_override'] = 'errors/page_missing';
$route['default_controller'] = 'main';
$route['register'] = 'register';
$route['auth'] = 'auth';
$route['login'] = 'login';
$route['logout'] = 'logout';
$route['photos/delete/(:num)'] = 'photos/delete/$1';
$route['admin/(:any)/(:any)'] = 'admin/$1/$2';
$route['admin/(:any)'] = 'admin/$1';
$route['admin'] = 'admin';
$route['upload'] = 'upload';
$route['(:any)'] = 'about_user';

Code:
public function index() {

  $data['isLogged'] = $this->autoload_model->isLogged();
  $data['temporary_data'] = $data;
  $this->load->view('main_view', $data);
}
public function contest($new) {
  $data['new'] = $new;
  $data['page'] = 'contest';
  if (strlen($new) > 0){
   echo $_POST['end_day'];
  } else {

   $data['isLogged'] = $this->autoload_model->isLogged();
   $data['temporary_data'] = $data;
   $this->load->view('main_view', $data);
  }
}

When i call admin/contest/new, $new returns nothing. So params aren't working. Why ?

Thanks.
#2

[eluser]xeroblast[/eluser]
Code:
$route['admin/contest'] = 'admin/contest';
#3

[eluser]Darker[/eluser]
[quote author="xeroblast" date="1351665731"]
Code:
$route['admin/contest'] = 'admin/contest';
[/quote]

You mean this ?
Code:
$route['admin/(:any)/(:any)'] = 'admin/$1/$2';
$route['admin/contest'] = 'admin/contest';
$route['admin/contest/(:any)'] = 'admin/contest/$1';
$route['admin'] = 'admin';
#4

[eluser]xeroblast[/eluser]
yes...
#5

[eluser]PhilTem[/eluser]
[quote author="Darker" date="1351683706"][quote author="xeroblast" date="1351665731"]
Code:
$route['admin/contest'] = 'admin/contest';
[/quote]

You mean this ?
Code:
$route['admin/(:any)/(:any)'] = 'admin/$1/$2';
$route['admin/contest'] = 'admin/contest';
$route['admin/contest/(:any)'] = 'admin/contest/$1';
$route['admin'] = 'admin';
[/quote]

Change it to
Code:
[...]
$route['admin/contest/(:any)'] = 'admin/contest/$1';
$route['admin/contest'] = 'admin/contest';
[...]

because routes are validated in a first-come first-serve way Wink
#6

[eluser]CroNiX[/eluser]
Except that order probably won't work.

More specific routes need to come first (most segments).
More specific named routes need to show up higher than those with wildcards, or the wildcard will match that segment before the named segment like
admin/contest/(:any)
should come before
admin/(:any)/(:any).
because if not, (:any) would match the "contest" segment and not route properly.
#7

[eluser]Darker[/eluser]
[quote author="CroNiX" date="1351697420"]Except that order probably won't work.

More specific routes need to come first (most segments).
More specific named routes need to show up higher than those with wildcards, or the wildcard will match that segment before the named segment like
admin/contest/(:any)
should come before
admin/(:any)/(:any).
because if not, (:any) would match the "contest" segment and not route properly.[/quote]

Thanks for your help, now i wanna ask the other question.

Code:
<?php
class Admin_model extends CI_Model {
function __construct() {
  parent::__construct();
}
function createContest($values){
  $query = $this->db->query("INSERT INTO contests SET author=?, start=?, finish=?, title=? ", $values);
  if ($query){ return true; } else { return false; }
}
}
?>
It's my admin_model.php. When i load this model there are some errors (but i can't see them, only blank space above page). Whats wrong there ?

Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB