• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Message: Undefined variable: meta

#11
[eluser]doubleplusgood[/eluser]
Awesome!
Worked perfectly, thank you so much.

Looks like the CI User Guide needs updating. Big Grin

[quote author="LuckyFella73" date="1252182196"]I didn't test this, but maybe this works

Code:
<?php

class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();    
    }
    
    function index()
    {        
        $data['meta'] = array(
                array('name' => 'robots', 'content' => 'no-cache'),
                array('name' => 'description', 'content' => 'My Great Site'),
                array('name' => 'keywords', 'content' => 'love, passion, intrigue, deception'),
                array('name' => 'robots', 'content' => 'no-cache'),
                array('name' => 'Content-type', 'content' => 'text/html; charset=utf-8', 'type' => 'equiv')
        );
        
        $data['link'] = array(
                  'href' => 'css/printer.css',
                  'rel' => 'stylesheet',
                  'type' => 'text/css',
                  'media' => 'print'
        );
        
        $this->load->view('welcome_message', $data);
    }
}

/* End of file welcome.php */
/* Location: ./base/yourappname/controllers/welcome.php */
[/quote]

#12
[eluser]LuckyFella73[/eluser]
You're welcome! Glad I could help a bit

#13
[eluser]SitesByJoe[/eluser]
I can't believe I missed that he was loading the view before assigning the arrays and not even passing the data over....how embarrassing...

#14
[eluser]doubleplusgood[/eluser]
[quote author="SitesByJoe" date="1252188142"]I can't believe I missed that he was loading the view before assigning the arrays and not even passing the data over....how embarrassing...[/quote]

Heh, we won't tell anyone. Big Grin

Thank you very much for your help guys. I'm now on the search for a script helper so that I can add script references in the head, but the html helper doesn't seem to offer this. Sad

#15
[eluser]LuckyFella73[/eluser]
If you need a solution to load javascripts depending
on the page that is loaded I can tell you what I do
(there may be better ways of course)

I have a config file where I define all needed javascripts - for example:
Code:
$this->js_formscript_news ='<scri+pt type="text/java+scri+pt" src="'.base_url().'js/formscripts_news.js"></scri+pt>';
$this->js_formscript_press ='<scri+pt type="text/java+scri+pt" src="'.base_url().'js/formscripts_press.js"></scri+pt>';
// and so on

In the contructor of my controller I load the config file
Code:
$this->load->file('system/application/config/config_admin.php', true); // for example

In the different functions (before calling the view files I
set the needed js in case I need one or more like this:
Code:
$data['js_import'] = array ($this->js_formscript_news,$this->js_formscript_press);

And at last in view file (header part of course) I have this:
Code:
&lt;?php
if ( isset( $js_import ) AND count( $js_import ) > 0 )
{
    foreach ($js_import AS $js_data)
    {
        echo $js_data;
    }
}
?&gt;

If somebody has a better solution I would be really interested in!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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