SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast antitoxic's Avatar
    Join Date
    Apr 2008
    Location
    London, UK
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to declare and manage Models for single pages (About, Welcome msg...)

    I'm working with symfony framework but it's not particularly relevant.
    When you create a model for a object (publication, article, cars, books) you know there'll be several of them.
    But what if you know certainly that there will be just 1 item. Just as the About page, contact page information, welcome messages.
    How do you define them ?
    Certainly they are not categories so that you can create a Category and use its description as content.
    They're single pages. Just as the CMS allows you to do. To create single page.

    How should I proceed and define them and afterwards to manage them in the admin pane ?
    They have different structure than everything else, but isn't this silly to create a table with a single row in it ?

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    How about you analyse all the differing content of "single pages", identify what features they all have in common, img, title, text etc along with optional features and create one model called "pages"?

  3. #3
    SitePoint Enthusiast antitoxic's Avatar
    Join Date
    Apr 2008
    Location
    London, UK
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought of that as an option.
    But wouldn't this bring a bit of blur in identifying them afterwards in the controllers. Even if we use some slug to identify them.

    We define pages as a model.
    Then create controllers About, Services, Welcome.
    In order to read the page our query should contain something as
    PHP Code:
    ->where('id= ?',1
    or
    PHP Code:
    ->where('slug= ?','about'
    Again we compromise the simple
    PHP Code:
    About->findFirst() 
    Yes, it's again not that clear as there in the database design there should not be more than 1 about page allowed but to call the method from About object seems so more elegant ?

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Are you trying to achieve a single controller, or a single model to manage 'pages' ?


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
  •