joshgilbert / incubator_mvc_framework

0 stars 0 forks source link

Major refactoring needed for views/templates/blocks #4

Open samtay opened 9 years ago

samtay commented 9 years ago

As we discussed, we need to modularize the construction of the HTML document response. This can be accomplished by making use of inheritance in View classes instead of having each template file be an entire HTML document.

samtay commented 9 years ago

@twslade just explained to me how your current set up can modularize the view. I did not realize that your setTemplate methods default to blocks and not pages. If you want to try to keep the current set up, that is fine, but you will definitely need to have a clear understanding of how you can reduce code duplication using the parent view classes (from which the .phtml files are called). For instance, some base classes to set blocks such as header/footer and extended classes to set content blocks such as blog title and blog entry text. The view class from which the content block template is included should have convenient data retrieval methods such as getTitle() and getEntryText() so that the content rendered by these blocks is dynamic and hence not duplicated.

@jdgilbert6 This is your app so you are free to choose whichever approach you like better, keeping in mind the timeline. We can meet back up later today if you want to, just schedule something on my calendar.

samtay commented 9 years ago

In addition, if you want to keep your approach, I'd recommend implementing some directory structure into your blocks so that it is clear which ones belong to which view classes. You don't want to be in a template file wondering what $this refers to. Documentation at the top of each file will help too.