Welcome Guest, Not a member yet? Register   Sign In
URL segment depth problems
#11

[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.';
  }
#12

[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.
#13

[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.
#14

[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;
#15

[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>
#16

[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




Theme © iAndrew 2016 - Forum software by © MyBB