1 Replies - 19984 Views - Last Post: 19 March 2013 - 06:48 AM Rate Topic: -----

#1 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 926
  • View blog
  • Posts: 3,205
  • Joined: 19-January 10

How should I go about doing this? (MVC question)

Posted 18 March 2013 - 10:08 PM

So I'm working on a rather large site... Includes forums (probably going to go with a prebuilt solution), a user system with rankings, teams for users to congregate, etc etc. Now - I'm working on the design and the general framework I will be using.

Now I'm working on an MVC framework right now... It's basically just this, where the request URL is parsed into /controller/action/id?extra_ parameters, controller is created, controller->action() is called, action loads into the $view element everything the view will need to properly setup the HTML, action then calls displayView and the proper view is loaded for the controller/action.

Now on the home screen, it's split into 3 columns. 12 being 100% wide, they are 3 (left), 6 (middle), and 3 (right) - just so you have a general idea of what it looks like. The columns there are multiple links and bits of info that will be pulled from the DB, one of which including a poll.

Now, I know I'm supposed to be the styling/html inside of the view for my poll information, but what if I want to put the poll somewhere else as well? I'd have to copy over the stuff that was in my homepage view - which would sorta ruin the point since now any changes will have to be done through multiple files.


So this leaves me with two options.


a. I can go sloppy (if you could call it that), and copy my poll view info wherever I intend for it to show up,

or b. I can make a placeholder script. The view information is stored in a variable using output buffering, so I could detect if something like {POLL:13} is in there and retrieve poll with the ID of 13, and possibly store the view stuff for these modules inside of another view folder (ie instead of views/(controller)/(action).php, it'd be views/modules/(module).php). I've done something like this with another client (before I used MVC), and he absolutely loved it because of the functionality it provided him (he could basically make very safe DB calls without knowledge of programming).

As I'm writing this out I'm thinking about it... I could possibly make a controller for these modules, and have an ajax-style call (framework is setup so I can retrieve the finalized result of a request all the way until right before the actual view is put inside the template - I'm not talking about an actual javascript ajax call), and have each module be the action? Yes. This idea makes this SO much more appealing.


It seems as if I may have solved my problem while typing it out, but I'd rather not waste my efforts in typing this and learn later on down the line that what I'm thinking of is wrong, so what would you do in this situation? Which option would you take? How would you handle this, basically?

Is This A Good Question/Topic? 0
  • +

Replies To: How should I go about doing this? (MVC question)

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2910
  • View blog
  • Posts: 10,075
  • Joined: 08-August 08

Re: How should I go about doing this? (MVC question)

Posted 19 March 2013 - 06:48 AM

It's been a while since I've used an MVC framework (spending most of my time in C++), but I think that ideally you want any view to be usable by any controller so your solution makes sense.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1