Welcome to WebmasterWorld Guest from 18.232.99.123

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

MVC logic

     
7:22 pm on Mar 6, 2016 (gmt 0)

Junior Member

5+ Year Member

joined:July 23, 2013
posts:59
votes: 0


Hello guys,I'm building small MVC based blog(site) project,and I'm bit stuck with logic.My goal is to to get it right...

So,on normal no-MVC projects that I have done the structure of website looks like this.

---overallheader(which consists from header,logo,navigation,etc)
--- content
--- overall footer(sidebar,etc)

The logic of MVC is just to pass data to view that we got from model using controller.No such things as database queries in view(etc..).

And the thing is that I don't understand is how to make navigation in template.I must grab it in every controller and send it in view?Also with some related posts or something like that.These things are somewhat independent from content(on non-MVC project I just require prepared file like navigation.php ).And I would have to repeat the code a lot.Then I will break the rule don't repeat myself(DRY).

I didn't find any material on the internet that will explain how to tackle this issue.

Tnx in advance guys!
10:29 am on Mar 14, 2016 (gmt 0)

Senior Member from ES 

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 11, 2003
posts: 1381
votes: 0


I think this is something you need to sort out based on your needs. How complex is the navigation? Will it be managed by the DB or entries somewhere?

As for the related entries, I've always treated that in the same manner as the overall idea of "mvc" (deliberate quotes there). Whatever calls the inclusion into the final view (control at some level) will have its model (get related posts based on some business logic) and view.