Search code examples
codeignitercode-reusecodeigniter-2

Codeigniter reusable sections


I have a table of data from a database that I want to display on various pages of my website. Ideally, i would like to just have an include or something that will go off and get the data, and return the html table. The html and data will be identical everytime I need to use this.

I wanted to know the best way of doing this

Thanks

EDIT

If this helps, something similar to a Django "inclusion" custom tag...for any django developers reading


Solution

  • Ok, so here is one thing that worked for me, but its definitely not perfect.

    I created a view in which made a call to the model getting the data then put the data into a table. This way, I only have to include this view to put the table anywhere.

    I understand this completely ruins the point of having a MVC framework, but hopefully it demonstrates what I want to do...and it works