Welcome Guest, Not a member yet? Register   Sign In
Load different data depending on URL?

Thanks for the reply TG.

I'm using your code for the Controller, but sadly this just loads 'category' when I access any scenario of the URL (see post #3).

Is there a cleaner way of doing this? Am I making it too complicated?

Thanks again for all your help.

Do you need me to provide you with any other files to help diagnose the issue?
My Routes file is (snippet):

$route['default_controller'] = "main";
/*$route['page/(:any)/(:any)'] = "page/pages/$2";*/
$route['login'] = "login";
$route[':any'] = "main/index/$1";  
$route['scaffolding_trigger'] = "";

[eluser]Alexandru M.[/eluser]
Maybe this will work (did not try it tough) :
if($param1 && $param2 && $param3)
  // Show info for the last parameter aka limited city information

else if($param1 && $param2)
  // Show info for the second parameter
else if($param1)
  // Country information
  // No parameters given

This way only one type of information will be shown (I think).

Need to dash out just now.

That also didn't work Alexandru Sad

Will come back soon and try again Smile

try this
function index($param_1 = FALSE, $param_2 = FALSE, $param_3 = FALSE) {

  $data = array('entities'=>array(), 'title'=>'', 'main'=>'public_page');

  if (empty($param_1) && empty($param_2) && empty($param_3)) {
    $data['title'] = 'no specific category chosen';
  } else {
     $data['title'] = !empty($param_1) ? 'country' : $data['title'];
     $data['title'] = !empty($param_2) ? 'city' : $data['title'];
     $data['title'] = !empty($param_3) ? 'category' : $data['title'];

  $data['entries'] = $this->Mains->get_entries($param_1, $param_2, $param_3);
If that does not work I think you need to confirm what values you are actually receiving for each of the params
add the following as the first statements for the function
echo $param_1.'::'.$param_2.'::'.$param_3.'<br />';
because i have a feeling the problem is that there is no controller and method in the url
the url should probably be
[controller] because i do not know what the controller is

Thanks for the reply and apologies for my delay.

That doesn't seem to work either.

When I try to echo those I get:

Severity: Notice

Message: Undefined variable: param_1

Filename: views/template.php

Severity: Notice

Message: Undefined variable: param_2

Filename: views/template.php

Severity: Notice

Message: Undefined variable: param_3

Filename: views/template.php

The Controller is [b]main[b].

Thanks again for your assistance. I've got a feeling I've perhaps missed something uber obvious.

so try going to the url http://www.site.com/index.php/main/index...ow/hotels/ and see if that works

This still shows 'country' Sad

also both show 'country'

Thanks again for your help.

I don't think it's recognising my param_1's at all Sad

Even visiting: http://localhost/ae/index.php/main/ still shows 'country'

You can't echo them in the template, they are not defined as template variables. Echo them (or better, use var_dump) in the index() method of the controller.

Theme © iAndrew 2016 - Forum software by © MyBB