Welcome Guest, Not a member yet? Register   Sign In
calling models within a view
#1

[eluser]xerosis[/eluser]
I am trying to create a CMS, now the CMS has a right hand panel on all pages that give a lot of information such as:

- Title of 5 latest news.
- Name of 5 users who's birthdays are today.
- Count of new payment requests.
- Count of new withdraw requests.
- Count of new unread Support messages.
- Another box displaying different status such as page view etc.

All of the above could be around 10 queries from different tables.

====

Basically I want to use MVC model, but in this case does my controller have to connect to different models and pass the data from the above queries (EVERY SINGLE TIME) as different arrays to the view? This just does not sound right. What if I add a new section to the right panel, must I go and modify all the controllers?

The way I am currently doing this is naming the right hand panel side_panel.php where I include in all pages and have the models called from within the view itself.

====

Basically this brings up a second question, I already have a model for news (add, edit, retrieve, delete functions) another for user, another for payment etc.
Must I create a specific model for all the side areas on the right hand panel or should I call all these different models when I want to list information only?

Thanks.
#2

[eluser]InsiteFX[/eluser]
Create a Library that loads you models

Then in you controller load the library and call the library methods to get the data.

Now if you need to update something it will be in your library and model.

Your second question: Create model say called Panel and add all your Panel Methods in it.

So now you would have Library (Panel) and Model (Panel_model)
Name then what you want but do not name them the same name.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB