CMS system with a twist!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikeb
Forum Commoner
Posts: 60
Joined: Tue Jul 08, 2003 4:37 pm
Location: Dublin, Ireland

CMS system with a twist!

Post by mikeb »

Hi,

Thanks to this forum I am now able to start using PHP having coded in CFML in the past. I am about to embark on a CMS site (for myself, not a client) but with a twist. Normally, my dynamic pages would be created when requested by pulling up a template and populating it with content from the db. This is fine and I can cache the pages to save my db being hammered.

This time I'd like to have html pages (with the .html extension) created and dumped on the server. My idea is to that this will provide help with search engine optimisation by providing a weight of read made html pages for spidering. So, when an administrator makes a content change, a new page is written to the server at that point and is available as a seemingly static page to the next visitor who requests it. This could be done either to each page as a change is made or perhaps by including a 'compile' button to recompile the whole site when needed?

Obviously I'm not looking for direct code help for this ('though not doubt I'll be spending time on the forum pulling my hair out) but would be interested in forum members' overviews on how I might approach the problem theoretcially. Feel free to tell me I'm insane to even attempt it :wink:
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

TBH, if you're doing this simply for seach engine spiders it's not at all neccessary - because PHP creates pages on the server-side the bots will only ever see the ready made web pages as if they were static.

Mac
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post by Heavy »

It might be good to have the extension .html on your scripts, since some webcrawlers ignore files with extension .php.

Someone else may confirm or deny this. I've read it somewhere but could not find any link to it fast enough to bother... :wink: Think it was about googlebot.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

It's not googlebot - that will happily crawl your pages .php or .html. Any good bot will be fine with .php pages as well as with dynamic links.

Mac
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post by Heavy »

twigletmac wrote:Any good bot will be fine with .php pages as well as with dynamic links.
This must mean that it could produce interesting results if one provides links between pages that actually trigger some db update action. I mean googlebot and others testing every <a href="blah"> it finds... It should mean that one shouldn't allow any spicy links to be displayed if a user is not logged in. Any bot in the world might trigger a special counter, poll or something. if it is designed poorly :?:

I always require users to authorize themselves in my systems, before letting them do anything.
Should one need to consider bots a data integrity risk?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

I recently created a site just like this. At the heart of the operation is:

Code: Select all

<?php

// .. declare vars for the page ..

ob_start();
include($template);  // an html template where page vars are echo'd
$html = ob_get_contents();
ob_end_clean();

// .. write $html to file

?>
The site's author has an (offline) database where he edits content.

A CSV export from this db is used to update the live site db (good old phpMyadmin - I didn't even have to write a script).

Finally, an admin page displays a list of options to write html files.

Whether you need several update options or one global site update depends. In the site I was working on, I think scripts were writing over a thousand files without timing out - certainly well into the hundreds. So, you could well get away with just a single global update.

As well as adding files for new items, site update scripts should overwrite older files where links need to be updated and delete old files for pages you no longer want to display.

It's good to have some error handling: ie, in a file-writing script, create a report (which you can print to screen and/or write to disk) which catches any failed file-writing operations.

The admin area might also include options to check if any required graphics have been uploaded.

Watch out for file owner/group UID issues.
Last edited by McGruff on Thu Aug 11, 2005 1:49 am, edited 1 time in total.
User avatar
Slippy
Forum Contributor
Posts: 113
Joined: Sat Jul 12, 2003 11:31 pm
Location: Vancouver eh!

Post by Slippy »

You could also tell Apache to parse .html files as .php if you don't mind the overhead.
Post Reply