Question

I'm currently working with Codeigniter and have one question. If i store basic siteproperties and information about a site, like site-title, side-slogan and stuff like that in DB. What's the best way to pick up the information and send it to everypage? Is the best way to do it in every function in the controller or is there any simpler method?

I've tried a __construct - function but can't understand how to send the variables.

So pleace. Help me.

Was it helpful?

Solution

Use a template layout to build your pages on - see http://williamsconcepts.com/ci/codeigniter/libraries/template/ for one you might like

OTHER TIPS

You can put a function in a helper file and autoload that from config/autoload.php

FYI you'll have to set up a new variable to replace $this when making DB calls. E.g.:

function siteStuff()
{
    $ci=& get_instance();
    $ci->load->database();
    $query = $ci->db->get('table');
    return $query->result();
}

Then get the array in your view with:

$array = siteStuff();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top