Welcome Guest, Not a member yet? Register   Sign In
New to CI, need some advice
#1

[eluser]josephfley[/eluser]
Hi,

First than all sorry my english isn't that good. Anyway I'm developing a small site with CI but have a few question:

1. Where is the best place to put utility functions and constants shared by the whole site? Helper? Library? somewhere else?

2. I have split my page layout into footer, header, products_box, etc... Then created the main views (the ones I load from the controller) where is page content and there I load the other parts, the problem is that I need to display dynamic data on those too, so I end passing all to the main view and there having to re-wrap things and passing then to the other views. Do you load each view from the controller to avoid this? Is there a better way to handle that?

Thanks a lot Big Grin
#2

[eluser]Pascal Kriete[/eluser]
First off, welcome to CodeIgniter!

1. Constants can go into application/config/constants.php. For utility functions, use helpers (autoload them to make them available globally).

2. You don't need to pass the data down to the nested views, it's available to all sub-views automatically.
#3

[eluser]josephfley[/eluser]
Both things seems obvius now.

If there was a point that made me choose CI was his community.

Thanks!
#4

[eluser]darkhouse[/eluser]
One thing I've been doing is any time I find I've got related helper functions, or if I seem to be repeating code over and over, I generally make a library to consolidate my code, and generally make it faster to do things on future projects. Plus doing things in libraries instead of helpers keeps you using object oriented programming (OOP).
#5

[eluser]josephfley[/eluser]
I see what you mean darkhouse, thanks for the tip. Big Grin
#6

[eluser]girish[/eluser]
hi josephfley,
this is girish who is curious to know about your success in managing header and footer.




Theme © iAndrew 2016 - Forum software by © MyBB