pass values from controller to constructor

#1
[eluser]livewirerules[/eluser]
im trying to set a title and meta description for each function in my controller and the below doesnt seem to be working.

below is the code im using

Code:
function __construct()
{

    parent::__construct();

    $info['title'] = 'No title';
   $info['descrip'] = 'No description';
    $this->load->view('include/header',$info);
}


function be_cool()
{

    $info['title'] = 'This is the be cool title';
    $info['descrip'] = 'This is the be cool description';
    $info['body'] = 'template/becool';
    

    $this->load->view('include/template',$info);
}

function be_hot()
{
   $info['title'] = 'This is the be hot title';
    $info['descrip'] = 'This is the be cool description';

    $info['body'] = 'template/behot';

    $this->load->view('include/template',$info);
}

can someone please help he how to get this working

#2
[eluser]jprateragg[/eluser]
Can you post your view(s) (include/template; include/header)?

#3
[eluser]livewirerules[/eluser]
template
Code:
$this->load->view($body);
$this->load->view('includes/footer');

header
Code:
<!DOCTYPE HTML>
&lt;html lang="en-US"&gt;
&lt;head&gt;
&lt;meta charset="UTF-8" /&gt;
&lt;meta name="viewport" c initial-scale=1.0" /&gt;
&lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
      &lt;meta name="description" c echo $descrip; ?&gt;"&gt;
&lt;!--[if lt IE 9]>
  [removed][removed]
  [removed][removed]
  [removed][removed]
<![endif]--&gt;
&lt;!-- The Fonts
&lt;link href="http://fonts.googleapis.com/css?family=Oswald|Droid+Sans:400,700" rel="stylesheet" /&gt;
  --&gt;
  
&lt;!-- The Main CSS File --&gt;
&lt;link rel="stylesheet" href="&lt;?php echo base_url();?&gt;assets/css/style.css" /&gt;
&lt;link rel="stylesheet" href="&lt;?php echo base_url();?&gt;assets/fonts/font.css" /&gt;
  &lt;link rel="stylesheet" href="&lt;?php echo base_url();?&gt;assets/css/validationEngine.jquery.css" type="text/css"/&gt;
&lt;/head&gt;

#4
[eluser]jesterhead[/eluser]
your loading your header before the appropriate title and description is set in your functions.

put
Code:
$this->load->view('include/header',array('title' => $title, 'descrip' => $descrip));
in your template


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.