Welcome Guest, Not a member yet? Register   Sign In
How do I need to do this? Library? Plugin? Helper? I don't know..
#1

[eluser]Gijs Bloemen[/eluser]
Hi all,

Last days I had some questions about CodeIgniter, the app that I am building with it is going nice at the moment. But now I get a new problem. I have been thinking but I do not know how you theoretical needs to do this to follow the MVC guidelines..

The header of my site needs to be the same every moment. No problem, just load the header in a different view so I can change the header by just change one file.

So at the moment I load my site in de controller as following:

Code:
$this->load->view('header');
$this->load->view('thispage..');
$this->load->view('footer');

This works fine. But now I want to parse some information out of my database in the header. So I want to know, how to do this, get everything out of the database in a library, plugin or helper? Wich one do I need to put the script to get the right information en put it in the right array.

Maybe it is a stupid question. But I like to do it good from the first time..

Regards,
Gijs Bloemen

(Excuse me for my bad English)
#2

[eluser]Maglok[/eluser]
You seem quite dutch to me. Smile So am I.

The MVC model is described in the user_guide. It whirls down to that you get your data from your database in the model. A library, plugin and helper are different.

There is a database library though, that helps you get the data out, which you should do in a model class.
#3

[eluser]Gijs Bloemen[/eluser]
[quote author="Maglok" date="1247680304"]You seem quite dutch to me. Smile So am I.

The MVC model is described in the user_guide. It whirls down to that you get your data from your database in the model. A library, plugin and helper are different.

There is a database library though, that helps you get the data out, which you should do in a model class.[/quote]

I am indeed Dutch.. Tongue

Yes I know. But the problem is I can put the query in a model, but after I got my information out of my database I have to calculate with it. The values I got than I have to output in my header view. So the problem is I have to write in each controller that calculations. So that calculations do I need that to put in a library, plugin or helper?
#4

[eluser]Maglok[/eluser]
Well officially libraries are 'part of the CI core', plugins tend to be one function and the helpers multiple.

Plugins: http://ellislab.com/codeigniter/user-gui...ugins.html
Helpers: http://ellislab.com/codeigniter/user-gui...lpers.html

If it is one calculation you have to run a lot, write a helper, autoload it and just call the function.

You could also just create a function in the controller and call that.
#5

[eluser]Gijs Bloemen[/eluser]
[quote author="Maglok" date="1247681258"]Well officially libraries are 'part of the CI core', plugins tend to be one function and the helpers multiple.

Plugins: http://ellislab.com/codeigniter/user-gui...ugins.html
Helpers: http://ellislab.com/codeigniter/user-gui...lpers.html

If it is one calculation you have to run a lot, write a helper, autoload it and just call the function.

You could also just create a function in the controller and call that.[/quote]

Hmm.. I am going to do it than with a helper, the calculation can change some times so it is better to just have one file I load all the times. If I want to change something I just have to change that one.

Thanks for your help.
#6

[eluser]Johan André[/eluser]
[quote author="Gijs Bloemen" date="1247682169"][quote author="Maglok" date="1247681258"]Well officially libraries are 'part of the CI core', plugins tend to be one function and the helpers multiple.

Plugins: http://ellislab.com/codeigniter/user-gui...ugins.html
Helpers: http://ellislab.com/codeigniter/user-gui...lpers.html

If it is one calculation you have to run a lot, write a helper, autoload it and just call the function.

You could also just create a function in the controller and call that.[/quote]

Hmm.. I am going to do it than with a helper, the calculation can change some times so it is better to just have one file I load all the times. If I want to change something I just have to change that one.

Thanks for your help.[/quote]

I don't know if it's the "proper" way to do it, but if the data returned always need to be modified before use, consider:

a) to modify the data in the model when it's fetched

or

b) modify the data before inserting it

or

c) create a helper to modify it




Theme © iAndrew 2016 - Forum software by © MyBB