Welcome Guest, Not a member yet? Register   Sign In
Best practise advice needed - where to put small PHP widgets within the app?
#1

[eluser]Peter Lachky[/eluser]
Hi guys,

as I am still new to CI and some areas are not quite clear to me I would like to ask you for an advice.

I am developing this application which, in browser, has the main content area and the right and left sidebars with some widgets, eg: search button, ads, list of categories, list of tags, current weather, etc...

My question is: Where do I put these widgets? Those are rather small pieces of code and I would like to keep them in separate files. However, these can not be views as some of them need to access the database. What is the best practise to achieve something like this?

Thanks for your time.
#2

[eluser]Colin Williams[/eluser]
These widgets, in my app, would exist in the main template view. If they require dynamic data, this would be supplied via $this->load->vars() likely in the controller constructor.
#3

[eluser]jedd[/eluser]
[quote author="Peter Lachky" date="1262508344"]
My question is: Where do I put these widgets? Those are rather small pieces of code and I would like to keep them in separate files. However, these can not be views as some of them need to access the database. What is the best practise to achieve something like this?
[/quote]

View partials can still be given data from the database, so this means that these widgets (or view partials) can still be views (ie. reside under the views directory somewhere).

Have a read of these two threads - they might provide a bit more insight into the general pattern.

[url="http://ellislab.com/forums/viewthread/109698/"]http://ellislab.com/forums/viewthread/109698/[/url]
[url="http://ellislab.com/forums/viewthread/110969/"]http://ellislab.com/forums/viewthread/110969/[/url]
#4

[eluser]wiredesignz[/eluser]
You might find my Widget plugin useful also. See my signature for the link.
#5

[eluser]umefarooq[/eluser]
@wiredesignz widget plugin is really nice and easy to use just like your controller give it try.




Theme © iAndrew 2016 - Forum software by © MyBB