peter_anderson Posted May 9, 2009 Share Posted May 9, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/157495-simple-cms/ Share on other sites More sharing options...
gevans Posted May 9, 2009 Share Posted May 9, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/157495-simple-cms/#findComment-830351 Share on other sites More sharing options...
wildteen88 Posted May 9, 2009 Share Posted May 9, 2009 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); } Quote Link to comment https://forums.phpfreaks.com/topic/157495-simple-cms/#findComment-830356 Share on other sites More sharing options...
peter_anderson Posted May 9, 2009 Author Share Posted May 9, 2009 yes, ACP is admin. OK. Thanks for the code. I'll have a bash and see if it works or not Quote Link to comment https://forums.phpfreaks.com/topic/157495-simple-cms/#findComment-830371 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.