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

[eluser]invision[/eluser]
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.
#12

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

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

[eluser]Alexandru M.[/eluser]
Maybe this will work (did not try it tough) :
Code:
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
}
else
{
  // No parameters given
}

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

[eluser]invision[/eluser]
Need to dash out just now.

That also didn't work Alexandru Sad

Will come back soon and try again Smile
#15

[eluser]tonanbarbarian[/eluser]
try this
Code:
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);
  $this->load->vars($data);
  $this->load->view('template');
}
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
Code:
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
http://www.site.com/index.php/[controller]/index/scotland/glasgow/hotels/
[controller] because i do not know what the controller is
#16

[eluser]invision[/eluser]
Thanks for the reply and apologies for my delay.

That doesn't seem to work either.

When I try to echo those I get:

Code:
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.
#17

[eluser]tonanbarbarian[/eluser]
so try going to the url http://www.site.com/index.php/main/index...ow/hotels/ and see if that works
#18

[eluser]invision[/eluser]
http://localhost/ae/index.php/main/index/scotland/glasgow/hotels/
This still shows 'country' Sad

http://localhost/ae/index.php/main/index/scotland/glasgow/
http://localhost/ae/index.php/main/index/scotland/
also both show 'country'


Thanks again for your help.
#19

[eluser]invision[/eluser]
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'
#20

[eluser]WanWizard[/eluser]
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