I've built a CMS for use with clients websites, obviously I'm pleased with the results.


There is a template file for the site, this is the layout of the site.
The actual content for each page is stored in a MYSQL database.
When a page is created in the CMS, it creates a page in the root of the website which basically includes 2 files and stores the Page ID. So when a visitor views the page, that code includes the template file and relevant PHP, retreives the content from the DB and places it in the content area of the template file....and thats the page.

Now, in the CMS you get a list of pages available on the site, when you choose to edit a page I've used FCKEditor to allow you to edit the content of the page. At the moment only the content area of the page displays in the editor.

Navigation is managed by the CMS, the user can add remove and edit navigation items, and choose to point the nav item to a link or a page on the site using a drop down list.

Rather than put all the code for the navigation in the template file, I have it in an include file, and the template file includes that file, so the menu is generated when the page is viewed.

Because the sites are build are for different clients, they want the CMS to do different things, so I've added the ability for me to create addon modules which I can put into the CMS, this might say allow a client to add news article to their site, or upload PDFs. This works similar to the navigation, where I put an include in the relevant part of the template file.

I hope I've not lost anyone there.

Now, I want to make improvements. The biggest one is that when a page is edited, rather than only showing the page content, I'd like to show the whole page. Now this is where the problem comes in. Rather than having include files for NAV and News etc, I was thinking of creating a blocks section in the CMS, so you can add or edit blocks, and what information would have been in the include file will now be stored in a database. Rather than having a template file, I was thinking of breaking it up into blocks as well, like a header block, footer block.

When a page is created, the CMS will build a file and automatically put the header, footer and nav block into the page. so the page might look like this...


So, the header and footer block would display the header and footer, the [editable] part would be what the user can edit. [POS] blocks would be positions where new blocks could be added. So lets say for example, I log into the CMS, create a nav block with PHP code in it to generate NAV from the database. I would then choose from a drop down list pos-top, pos-left, pos-right, this what determine where I want the NAV block to appear. Behind the scenes, each [POS] would pull from the database all the blocks for that position, and include the code from the database for each specific block.

My problem is, when you want to edit the page in the CMS, i'll have to get the page to generate all the HTML of the page, which I'm assuming I'll store in a string. So basically, get the code for the header block, then parse any PHP, store the text in a string. Get the code and parse all PHP for all other blocks on the page and add the text to the string. I would then output this string to FCKEditor. The only thing is, I'm not sure this would work, or what complications I would come across. I know all about eval(), so I know I can parse PHP code stored in mysql and probably do $string = eval($header);

Once the page has been edited, I'm thinking that PHP would get the text from FCKEditor and explode or split it by [EDITABLE], discard anything not in between the editable tags and store the editable text in the database against that page.

Would all this work, what problems might I come across, or maybe theres a much easier solution for what I'm trying to do.

Maybe I could store the whole template as one in the DB, with something like [CONTENT] where the content should appear. Then when the page needs to be displayed read the template from the DB, replace [CONTENT] with the page content, and eval() the whole string so that any php within the code will get parsed. But then that leaves me with a problem of blocks.

I'm decorating at the minute, so for anyone whos been in the position you'll know what it's like. I've got some music going, and while I'm playing I have absolutely loads of ideas and doubts in my head about how to go about this.

If I don't get any replies I'll assume it's because you all got board reading