SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Finland
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic site hierarchy for CMS

    Hi!

    I desided to write my own small CMS where is only things that I need for my personal projects.

    The first thing I'm trying to implement is dynamic site hierarchy and this is where I need your advices.

    User should have the possibility to create that hierarchy... I mean something like that:

    Code:
    +Home
      -- Company
      |   -- History
      |   -- Ownership
      -- Products
      -- Contact
    User should be able to add and remove sites wherever he want.

    What would be the best solution for me? Database? Folders and subfolters? Anything else?

    I would appreciate all advices, articles, source code and anything related this issue.

    Thanks.


    - Konstantin
    Last edited by constans; Feb 19, 2005 at 01:24.

  2. #2
    SitePoint Evangelist comfixit's Avatar
    Join Date
    Dec 2004
    Location
    Pasadena
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am actually starting work on the exact same type of project. I find that most CMS sites today are geared to community sites where as I am trying to create a web development system that will allow clients to maintain the sites I create for them.

    So I have lots of suggestions on the topic. Just some random thoughts thrown out:

    I would suggest storing the primary content of the pages in a database. The reason is you can then use WYSIWYG editors such as http://www.fckeditor.net

    You will probably want to seperate out global information that will appear on all pages such as menu bars, headers and footers. These should be stored either in another field in your database or hard coded as files.

    Perhaps as a first start you should just create a basic PHP file that looks for an argument passed along the URL and loads the content from the database. The file can load all the Header, Footer and Toolbars etc that are common using include files.

    The primary content would be the only thing that is dynamic.

    Once you have that working then you can start creating a back end and try to integrate one of the <textarea> WYSIWYG editors so users can modify content.

    Then after that you can try to impliment a simple means for users to add and remove pages into the database.

    Then you will probably want your menu's to be automaticaly generated based on the names of the pages being added and removed.
    http://css.maxdesign.com.au/ is a link to a site that shows you how to make CSS menus that you can probably automate without too much trouble.

    That should give you a pretty good framework to start with that you can build on. Better not to add too much more then that functionality wise on a first pass otherwise the scope of the project will become too huge and you might lose momentum.

    This could be accomplished on a veriety of platforms. But since we all like free consider using PHP, MySql, FckEditor and CSS and perhaps DHTML if needed for the menu's.

    If you would prefer to team up on my project then drop me a note and I can pass along some more information on the scope of what I am doing and what you can contribute.

  3. #3
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Finland
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    comfixit, thank you for your numerous suggestions and great links! I've already implemented some of your suggestions such as page template model and now finishing WYSIWYG editor integration. I'm very satisfied with framework I've created so far as there's only what I really need and it's very simple and small.

    It would be exciting to team up and do something in co-operation with you. I'll contact you when I'm done with this. For now, I want to finish this feature and strike while the iron is hot!

    Back on topic...

    I've been thinking on this problem and came up with some idea. I really would like to hear your opinions on it before I start to implement it.

    I thought that I store all my pages in a single folder and meta data such as top page in database. Here's model solution:
    Code:
    DB Table: PagesLevel1
    +---+-------------------------+-----------------------------+
    |id |pagename                 |filename                     |
    +---+-------------------------+-----------------------------+
    |71 |Company                  |company.php                  |
    +---+-------------------------+-----------------------------+
    |72 |Releases and publications|releases-and-publications.php|
    +---+-------------------------+-----------------------------+
    
    DB Table: PagesLevel2
    +---+--------+---------------+------------------+
    |id |parentid|pagename       |filename          |
    +---+--------+---------------+------------------+
    |128|72      |Annual reports |annual-reports.php|
    +---+--------+---------------+------------------+
    |155|71      |Concact        |contact.php       |
    +---+--------+---------------+------------------+
    
    Filesystem: folder: pages
    
    company.php
    releases-and-publications.php
    annual-reports.php
    contact.php
    With foreign keys working, heirarchy would look like this:
    Code:
    + Home
      - Contact
    + Releases and publications
      - Annual reports
    Levels can be increased by simply creating new tables: PagesLevel3, PagesLevel4, PagesLevel5 ...

    The challenge with this type of solution is to make sure that there wont be any chance to overwrite or remove existing files by accident.

    Is there any known pitfalls in this solution? Let me know if I'm misleading myself.

  4. #4
    SitePoint Evangelist comfixit's Avatar
    Join Date
    Dec 2004
    Location
    Pasadena
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The solution you have proposed will work well to manage the navigation elements. I can easily see you using this structure in conjunction with code to auto generate a DHTML navigation bar for the page.

    However to me it looks like your using static PHP files (ie. contact.php) when with a database generated site it could easily be something like ( index.php?pageID=contact ).

    Your index page would probably be made of some include statements. One include for the header, the navigation, the body and the footer for example. Each of those includes would be responsible for loading the information from the database. I would suspect that in a very small project the include for the header, navigation and footer would staticly pull information from a given field in your database.

    The body include would strip the ID off the URL and use that to identify which field it should pull its information from.

    Now this is not the most search engine friendly or optomized way to do things if your getting hit thousands of times an hour but given small personal sites I think that it's a pretty resonable comprise of simplicity and proccessing load.

    So in my opinion your project could benefit by having:

    * A single file that is responsible for displaying the site. That file can substitute the body HTML based on what parameter is passed. If no parameter is passed it defaults to the home page. This will make it vary easy to impliment your WYSIWYG editor
    * If you impliment tip #1 then you may want to substitute the file name for page names in the database and you can use the pageName just as easily as the ID to look something up in a small database as long as it is unique.
    * I like the levels. Keep those. Like I said before with that structure you should be able to develop a script that can generate multi level drop down menu's dynamicly. But instead of using a seperate table for each level, since they basicly contain the same fields just add a Level field and put all the pages in one table. It will make searches and lookups much less complicated from a coding perspective.

    Impliment those three changes and in my opinion you have a solid structure for small scope projects.


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
  •