Welcome Guest, Not a member yet? Register   Sign In
Trouble with system vars
#8

[eluser]The Beginner[/eluser]
Quote:Show the code sections for:
o controller, where you set your header_logo variable,
o controller, where you call the view,
o view, where you use the header_logo variable.

Ok, first the controller loading data:

Code:
$this->db->where('wp_header_active', '1');
$querydata = $this->db->get('wp_header_data');
if ($querydata->num_rows() > 0):
  {
     foreach($querydata->result() as $row):
      {    
       $data['header_logo'] = snappy_image($row->wp_header_logo, 'My Picture', 'somestyle');
       $data['title'] = $row->wp_header_name;
       $data['site_name'] = $row->wp_header_name;
      }
     endforeach;
   }
endif;
$querydata->free_result();
$this->template->set('title', $data['title']);
$this->template->set('header_logo',$data['header_logo']);
// Load the template
$this->template->load('template', 'wpHeader');

This is my template.php, the plan is to load my header view, menu view contents and then my footer.
Code:
<html>
<head>
    <title><?php echo $title; ?></title>
</head>
<body>
    <div id="header">&lt;?php echo 'header'; ?&gt;</div>
    <div id="menu">&lt;?php echo 'menu'; ?&gt;</div>
    <div id="contents">&lt;?php echo $contents; ?&gt;</div>
    <div id="footer">&lt;?php echo 'footer'; ?&gt;</div>
&lt;/body&gt;
&lt;/html&gt;

Now the view:
Code:
&lt;?php
   echo $header_logo;
?&gt;

And that is it...... the error I get is :

A PHP Error was encountered
Severity: Notice

Message: Undefined variable: header_logo

Filename: views/wpHeader.php

Line Number: 2


Messages In This Thread
Trouble with system vars - by El Forum - 09-26-2009, 06:28 PM
Trouble with system vars - by El Forum - 09-26-2009, 06:31 PM
Trouble with system vars - by El Forum - 09-26-2009, 08:53 PM
Trouble with system vars - by El Forum - 09-27-2009, 05:11 AM
Trouble with system vars - by El Forum - 09-27-2009, 10:08 AM
Trouble with system vars - by El Forum - 09-27-2009, 12:14 PM
Trouble with system vars - by El Forum - 09-27-2009, 02:11 PM
Trouble with system vars - by El Forum - 09-27-2009, 03:34 PM
Trouble with system vars - by El Forum - 09-29-2009, 03:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB