SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2010
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MVC: Repeating content

    How do you guys handle includes for html that gets repeated through many pages while keeping MVC in mind?

    IE. Footers, side navigation, etc etc.

    Do you just do a include? Or assign a variable to hold the include and echo it out in the html side?
    Last edited by mizwizzy; Apr 9, 2010 at 17:59. Reason: thread cleanup

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,151
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by proxi
    How do you guys handle includes for html that gets repeated through many pages while keeping MVC in mind?
    I separate out things like that into their own controller making it possible to reuse them anywhere.

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2010
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I was just thinking about it, and my logic was off a bit. I was separating pages into individual ones even though I could have just done something like: domain.com/page/view/other/params


    PS. Didn't mean to hijack the thread

  4. #4
    SitePoint Addict Mastodont's Avatar
    Join Date
    Mar 2007
    Location
    Czech Republic
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Footers, side navigation etc. may contain dynamic parts, dependent on main content ... so separate controller bound to some Context dispatcher is a way to go.

  5. #5
    SitePoint Guru
    Join Date
    Jun 2006
    Posts
    638
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try to never have any duplicated code in your site.
    If you have a header on 2 pages, then make it an include.
    If your selected page needs to be highlighted, then add that code in the included header.

    Do this until you learn more PHP and get some experience with websites.

    After you make a few sites, you will notice the need for front controllers (chances are so far your using page controllers).

  6. #6
    SitePoint Zealot
    Join Date
    Feb 2009
    Location
    Bristol
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have nested view objects:

    1: make a master view for whole app - kick off output buffering on app startup
    2: nominate a master layout template
    3: inject view helper into each controller class - start new output buffer
    4: render controller output into the view for that controller
    5: flush controller view output into a variable
    6: render that variable into the master template


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •