Jump to content

Recommended Posts

Hi,

 

I am working on a website for a kids football team in my area, and I have decided to create a simple CSS (since the coaches have no HTML experience).

 

It's a simple script which includes a .txt file from /articles on article.php?a=ARTICLE_NAME

 

Here's my article.php:

<?php

# Retrieve Theme
$html = file_get_contents('./theme/theme.html');

$sArticleDirectory = './articles/'; //enter the path to your articles directory (/articles)
$sArticleName = isset($_GET['a']) ? $_GET['a'] : 'default' ;
$sArticleFile = $sArticleDirectory . $sArticleName . '.txt';

$html = str_replace('{content}', @file_get_contents($sArticleFile), $html);

	# Output Content
	echo $html;
?>

 

Now, I need the ACP. I will .htpasswd protect it, but I can't think of the best way to do the ACP.

 

It needs to get the file, and load it into FCKEditor, and once done it should save it.

 

Can anyone point me in the right direction? I'm stuck :)

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/157495-simple-cms/
Share on other sites

If I'm following you wannt to open the file. get the content of it into a textarea. On submitting the textarea the updated content gets saved to the file...

 

to start with, lets look at the file;

 

<?php
$file_content = file_get_contents("your-file");
echo '<textarea name="content">'.$content.'</textarea>';

 

This will put the content into a variable and echo it out in a textarea. Building a form around it you can submit the form. When the forms been submitted you can do the following to save itl

 

<?php
$handle = fopen("your-file", "w");
fwrite($handle, "form submitted content");

 

That will simply open the file. The "w" means that it will open the file and delete all teh content before using it (if it doesnt exist it tries to make it). fwrite will write the sumbitted content (probably via $_GET) to the file.

Link to comment
https://forums.phpfreaks.com/topic/157495-simple-cms/#findComment-830351
Share on other sites

EDIT: Beaten to itc ;)

 

By ACP I presume you mean Admin Control Panel?

 

For the ACP you're be basically doing the exacpt same thing as you'e doing in article.php. Except this time you're allowing for the article to be editted.

 

All you need to do is come up with a simple form with two fields and a submit button.

 

The first field will be for the article name.

The secoud field will be a <textarea></textarea> where the actuall article can be editted (FCKEDitor replaces this with a graphical WYSIWYG editor)

The last will be submit button.

 

When the form is submitted you'd write the new contents to the .txt file. Baisc example

if(isset($_POST['submit']))
{
    $sArticleDirectory = './articles/';

    $sArticleName    = $sArticleDirectory . str_replace(' ', '_', $_POST['article_name']) . '.txt';
    $sArticleContent = $_POST['article_content'];

    file_put_contents($sArticleName, $sArticleContent);
}

Link to comment
https://forums.phpfreaks.com/topic/157495-simple-cms/#findComment-830356
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.