CodeIgniter Forums
URL segment depth problems - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: URL segment depth problems (/showthread.php?tid=8686)

Pages: 1 2


URL segment depth problems - El Forum - 05-27-2008

[eluser]Michael Wales[/eluser]
A link to domain.com/wizard/wand/huge/green:

Code:
class Wizard extends Controller {
  function wand($size = 'small', $color = 'red') {
    echo 'This wizard has a ' . $size . ' ' . $color . ' wand.';
  }



URL segment depth problems - El Forum - 05-27-2008

[eluser]Tom Glover[/eluser]
I never knew you could do that. it will save me so much time not having to place segment commands all over my code.


URL segment depth problems - El Forum - 05-27-2008

[eluser]floweringmind88[/eluser]
I understand that part. I mean outside of the class in the view. When I try to access the variable in the view it is null as I am not addressing it correctly.


URL segment depth problems - El Forum - 05-27-2008

[eluser]Michael Wales[/eluser]
Code:
class Wizard extends Controller {
  function wand($size = 'small', $color = 'red') {
    $data['size'] = $size;
    $data['color'] = $color;
    // Note the 2nd parameter here - passing our array (or an object) of vars
    $this->load->view('wands', $data);
  }
}

Code:
<body>
  <h1>&lt;?= $size; ?&gt; &lt;?= $color; ?&gt; Wands!</h1>
&lt;/body&gt;



URL segment depth problems - El Forum - 05-27-2008

[eluser]neilw[/eluser]
Quote:Relative paths do not work in CI.
If that's so, why has the default welcome page:
Code:
<a href="user_guide/">User Guide</a>



URL segment depth problems - El Forum - 05-27-2008

[eluser]Michael Wales[/eluser]
Quote:If that’s so, why has the default welcome page

Saying that they don't work is a bit of an overstatement I think, they do - CI can't change the basic functionality of your browser.

But... trying to keep track of where you are currently located and what the relative path to each controller/method would be a pain in the ass, quickly getting into the realm of damn near impossible. It's so much easier to use the functions EllisLab provided for us - and why not, that's why you are using a framework, remember?

On the topic of the welcome page: the user guide is not part of the application - therefore it's really easy to link to it. Plus, for those of us who have quite customized how our development environment is laid out - that link doesn't work. Big Grin