Can someone please tell me how to invoke a method from the codeigniter controller when the page loads? What I want to do is to fetch some data from database and put it inside meta tags before page actually load. I obviously want to do it inside header. It should be something like this:
method, which fetches some data from db and returns it
<meta property="og:title" content="<?php echo $returnedValue; ?>"/>
Can someone give me a hand with this one? Thanks.
The page only loads after your controller loaded the view. So run your method before you call the view and add the result to the $data array, then load the view with the $data array as a parameter.
Now
$returnedValue, in the view, holds the return value of your method.echoit in the view wherever you want to include it.