CodeIgniter Forums

Full Version: How to implement reusable widgets?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

i want to display the product top ten on several pages. What is the best way to do that? The data are stored in a database. Should i create a function in my_controller or is there another way (Library)? There is not only a product top ten, there are also other cases (eg. last viewed products).
(06-13-2016, 01:03 PM)groovebird Wrote: [ -> ]Hi,

i want to display the product top ten on several pages. What is the best way to do that? The data are stored in a database. Should i create a function in my_controller or is there another way (Library)? There is not only a product top ten, there are also other cases (eg. last viewed products).

I am a fan of this concept, but achieving it in CodeIgniter 3 requires third-party stuff to be installed and tested. The bare minimum is https://bitbucket.org/wiredesignz/codeig...sions-hmvc

I use my MIT-licensed CI-based platform with HMVC that adds some comfort in creating visual widgets https://github.com/ivantcholakov/starter...-edition-4
See this sample page, the section "Widgets" http://iridadesign.com/starter-public-ed...wig-parser

Actually, right now am am doing such a work, see the attached image. The visual theme is taken from here https://github.com/dragdropsite/mPurpose
Hi,

this sounds good but is it possible to implement this in an existing application?
Install HMVC by wiredesignz, version 5.5 claims to be compatible with CI3. Then within your view you can make something like this:

Code:
foreach ($items as $item) {
    echo Modules::run('product_item_widget/index', $item);
}