...

View Full Version : XML-Based CMS



mark87
01-11-2006, 05:00 PM
Following on from an earlier post (http://www.codingforums.com/showthread.php?t=76713)...

I've created the forms etc, I just need a way to save dates+events to an XML file. eg.

<event>
<date>01.01.06</date>
<description>Blah</description>
</event>

Now, there'll be many events; and as well as adding an event to the XML file I'll need a way of displaying the information from the XML file onto a page, in date order.

Any ideas on how to do this?

firepages
01-11-2006, 05:39 PM
...Now, there'll be many events; ...in date order.

Any ideas on how to do this?

yes , don't use XML use a database :D ,
... ok I just read the other thread and see that is not an option, so while XML is fine for storage it is not (even with Xpath (simpleXML in PHP5 etc)) a good medium to search and query especially with say hundreds of records.

I would suggest 1 XML file per item and keep another index file (you are now creating a database :thumbsup: ) with either XML if you must or much faster PHP arrays of indexes , you can keep that index in date order and even with a few hundred entries it wont be too much work for PHP to load and mung..
(ksort() is your friend here)

e.g. in the below array '1' would relate to article /blah/1.xml dated 2006/jan/10 ( I like that YYYYMMDD timestamp format since its easy to perform simple greater than or less than logic on it)



<?php
$idx=array(20060110=>1,20060111=>2,'etc');
?>


OK now you probably have to include multiple XML files which is in itself not the most efficient way to go about it but I think far better than parsing a ?kb XML file.

mark87
01-11-2006, 10:10 PM
Thanks, hmm sounds a bit complicated.

How about... (and it's really basically scrapping the XML idea), because I know who'll be using it, just to basically have one textarea, whatever text is in there gets saved to a flat file, and then then the text is displayed on a page (although I'm not sure how the formatting could work - don't really wish to use a rich text area). The text from the text file would also have to be brought up into the textarea when the editing page loads.

How would this be done? (I mean, I know that the text can be displayed on a page using an include; but what about the rest?)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum