Content management system

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
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Content management system

Post 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.
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post by wtf »

User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

I thought of using a database, but I am guessing this will not be search engine friendly?

Rob.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply