Welcome Guest, Not a member yet? Register   Sign In
passing data to the view
#11

[eluser]strattonbrazil[/eluser]
By the way, I don't think the file attached correctly the first time. The view should be attached now in a zip file.
#12

[eluser]strattonbrazil[/eluser]
Could this have anything to do with the routing options I've setup? Right now when I type in

http://localhost/project/dashboard

it changes to

localhost/project/dashboard

Is that a possible problem? This whole passing-date-to-the-view seems to be pretty fundamental to me using codeigniter. Sad
#13

[eluser]strattonbrazil[/eluser]
I downloaded a new version of codeigniter and replaced just the views and controllers (and the default controller), and I get the same error, so I don't believe it's a routing thing I've done. Could it be something in my LAMP configuration?
#14

[eluser]Nick_MyShuitings[/eluser]
Your computer, or some ancestors... hate you. Thats the only explanation.

In seriousness, that is very weird, and completely un-reproducible...

What lamp stack are you working on? XAMP? WAMP? Linux native? that shouldn't have anything to do with it, since this is literally just passing an array...
#15

[eluser]strattonbrazil[/eluser]
[quote author="Nick_MyShuitings" date="1294466361"]Your computer, or some ancestors... hate you. Thats the only explanation.

In seriousness, that is very weird, and completely un-reproducible...

What lamp stack are you working on? XAMP? WAMP? Linux native? that shouldn't have anything to do with it, since this is literally just passing an array...[/quote]

LAMP. How exactly is it passed? I've seen examples where they're passing three parameters to view. What's that all about?
#16

[eluser]Cristian Gilè[/eluser]
It's a very bad practice putting functions inside view. Here, a more elegant solution:

in your controller:
Code:
class Dashboard extends Controller {

function Dashboard()
{
parent::Controller();
}

function index()
{
$data['controller_name'] = $this->router->fetch_class();
$data['links'] = array('Dashboard','link1','link2','link3'); //and so on. You can get them from your model

$this->load->view('header');
$this->load->view('header_bg');
$this->load->view('navigation_bg',$data);
$this->load->view('main');
$this->load->view('future');
$this->load->view('footer_bg');
}
}

in your view:
Code:
<div id="navigation-bg">
  &lt;!--Navigation Part Starts --&gt;
  <div id="navigation">
    <ul class="mainMenu">
&lt;?php
foreach($links as $link)
{
  if(strtolower($link) == strtolower($controller_name))
  {
    $attributes = array('title' => $link, 'class' => 'your_link_class');
  }
  else
  {
    $attributes = array('title' => $link);
  }
  
  echo '<li>'.anchor($link, $link, $attributes).'</li>';
}
?&gt;
</ul>
    <a href="#" class="signup" title="signup now"></a>
    <br class="spacer" />
    <ul class="subNav">
      <li class="noBg"><a href="#" title="Our Benefits">Our Benefits</a></li>
      <li><a href="#" title="What Our Future Plans">What Our Future Plans</a></li>
      <li><a href="#" title="Our Success">Our Success</a></li>
      <li><a href="#" title="Ratings">Ratings</a></li>
      <li><a href="#" title="Latest Blogs">Latest Blogs</a></li>
      <li><a href="#" title="News">News</a></li>
      <li><a href="#" title="Testimonials">Testimonials</a></li>
      <li><a href="#" title="Comments">Comments</a></li>
    </ul>
    <br class="spacer" />
  </div>
  &lt;!--Navigation Part Ends --&gt;
</div>
&lt;!--Navigation Background Part Ends --&gt;
#17

[eluser]strattonbrazil[/eluser]
Okay, I'll do that.

I did figure out the problem. The variable was being passed, but was outside the scope of the function. I realized it when I swapped out the function for just $controller_name and it worked, so I looked up PHP scoping (since I haven't done PHP in years).




Theme © iAndrew 2016 - Forum software by © MyBB