Page 1 of 1

Content management system

Posted: Thu Nov 17, 2005 12:15 pm
by spacebiscuit
Hi,

I have to post news articles on a website every couple of days. I use a html page as a template and simply cut and paste the textual paragraphs into the html and then save the page as a different name.

I'd ideally like to use php to automate this process. I have a test script working, I provide the user with an input screen and via a form I post this data (such as article title, sub heading, paragraph1, paragrap2 etc,.) to the template page.

Now on the template page I can echo the relevant variables to the screen so that on screen the process works, but my question is........ will it be possible to save the template file as say "newsarticle_2" with the form data variables as hardcoded text.

Therefore each time an article is submitted a new page is created and saved.

Any ideas, if so how do I do this.

Thanks,

Rob.

Posted: Thu Nov 17, 2005 12:27 pm
by wtf

Posted: Thu Nov 17, 2005 12:28 pm
by BDKR
If you have access to a database, why not store the particulars of the articles there. When you need the story, pull it from the database and populate the template with the data.

Cheers

Posted: Thu Nov 17, 2005 12:46 pm
by pickle
Ya, you could do that. If you're echoing the template page, you can capture that and put it in a string. You can then write that string to a file.

Code: Select all

ob_start();
echo $contents_of_template;
$complete_page = ob_get_contents();
ob_end_clean();

$fh = fopen('testpage.html','w');
fwrite($fh,$complete_page);
fclose($fh);
~BDKR has the best idea though. It's best to store it in a database. That way its way easier to edit the page after the fact. Also, if the template changes, it's much easier to put database content into a template, rather than having to pull the content out of an html file and put it in a new one.

Posted: Thu Nov 17, 2005 1:02 pm
by spacebiscuit
I thought of using a database, but I am guessing this will not be search engine friendly?

Rob.

Posted: Thu Nov 17, 2005 1:11 pm
by twigletmac
robburne wrote:I thought of using a database, but I am guessing this will not be search engine friendly?
No reason why it shouldn't be - decent search engines can cope with dynamic URLs.

Mac

Posted: Thu Nov 17, 2005 1:57 pm
by pickle
In most cases, database systems will have URLS like: http://www.domain.ca/page.php?id=sunday_blog

You can use .htaccess (providing you're using Apache) files to create an imaginary URL like http://www.domain.ca/sunday_blog which will show the above URL. There are lots of tutorials on how to do this.