Correct way to make data available to blocks?
Hi - I am a bit of a newbie - so forgive the basic question:
I want to include a (sidebar) panel of data on a few of my website pages (shows relationships between users and status info) and I want to have flexibility over which pages this appears on (will change over time). To me this sounds like a good application of a block.
The examples of blocks (e.g. quotes and projects) use modules - which I think I understand. However the data I am considering is data that is inherent to my application and not anything that I need to expose in the CMS and so I don't think a module is appropriate (correct me if I'm wrong).
My question is : what is the best practice way of exposing data to my block view?
- It doesn't have it's own controller as it is (dynamically) included into other views
- I could directly call the relevant model but this sounds like it would be a no-no in MVC terms
- I could make the data available to every view, but this feels inefficient
I understand this is probably more an MVC/codeigniter question, but it is the use of blocks that has triggered the problem for me.
Thanks in advance for any guidance you can give
Comments
<?=fuel_block(array('view' => 'my_block', 'vars' => array('my_var1' => 'my_var_value1')))??
// from within views/_blocks/my_block.php $data = fuel_model('my_model'); foreach($data as $key => $val): echo $val->my_prop; endforeach;
$CI->load->model('my_model'); data = $CI->my_model->find_all(); ....