[eluser]MTWIGG[/eluser]
[quote author="Aken" date="1313211989"]I don't see why you'd want to do it that way - so you're saying you'd have at LEAST five server requests for a single page load, and even more depending on the number of galleries there are?[/quote]
Maybe that was a bad example. I was simply trying to come up with a situation where you are using the same controller multiple times on the same screen with different information. In the example I was placing them all together but it could be that in one case the div was top left of the screen and the other one bottom right.
[quote author="Vheissu" date="1313231891"]There shouldn't be any situation where you need to call a controller. Controllers are nothing more than model interfaces really. Wouldn't it be best to have your functions that create the polls and fetch the comments be inside your model as presumably they're interfacing with the database anyway to get the information? You can call models from inside views.[/quote]
The poll results will change depending on the users interactions with the screen so when the screen first loads the code will be called to create the poll graph, but then the
same code must be callable via an Ajax call when the data is changed, hence since the Ajax will call a controller I thought "shouldn't the same controller be able to be called to create the original screen?"
My understanding of CodeIgniter (and I am a newbee) was that the
Controller defines the
data and the
Body/View defines the
layout. If, therefore, I wanted to include (for example) a DIV that contains a diary then as that diary will be defined by both data
and layout it is a Controller I should be loading.
However, from your response it seems as though what I should be doing is writing a 'naked' view (with no controller) for the diary or poll results (or any other type of re-usable DIV) which calls Models to get the data it needs. If, and only if, I also need to be able to call the same DIV from an Ajax call do I need to create a Controller which does nothing more than pass the Ajax variables into the view via an appropriate $this->load->view call.
Have I got this right?