Welcome Guest, Not a member yet? Register   Sign In
Using Preloaded Model Via BaseController in Other Controllers
#5

@includebeer My idea is to have a shared model, (the 'base layout markup'), which will set up the layout view and the renderSection() content is obtained via the specific controller.

When using the extend() function in the content, the layout view inherits the data.

The controller calls its model, (which will most likely have a db table), this model will extend the shared 'base layout markup', so has access to its functions to gather the layout view data.

Ultimately the 'base layout model' and its associated table will have meta data, HTML title tags etc to create the page, which will be determined by the URI segments, i.e., domain.com/segment-one/segment-two will query the db table for 'segment-one' and 'segment-two' for the page layout.  Hence why I need the request service so I can obtain the URI segments.

What is the best way to obtain the URI segments in the model?  Or should I use the controller to pass $this->request to its model, which then passes it to the 'base layout markup' model?

My strategy is to have a db table to contain meta data, HTML tag data to generate the layout view, and then its associated content can be in its own table.  This can then be edited / updated etc in an Admin area.

Alternatively, all of the page's markup and content will be in one table, (and not use the layout view / renderSection() function), which will be queried using the URI segments, which more or less leaves me with the same issue, obtaining the URI segments.  But I would like to separate those concerns; update one layout view rather than have to update it for each view for a controller if it requires update.

Hope that makes sense for my thinking :-)

I love the idea of Codeigniter allowing developers to do it 'their way' in some respects.  However, as you mention, I also wish to stick to the MVC pattern as much as possible.
Reply


Messages In This Thread
RE: Using Preloaded Model Via BaseController in Other Controllers - by Mr Lister - 10-11-2021, 03:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB