Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-16-2005, 09:18 PM Content Manager
Junior Talker

Posts: 4
Trades: 0
I made a great web site ( I think ) in CSS and HTML 4.0 for a customer. They have a new box that they need updated all the time it seems and they want control over it. I know I need a nice content managment system but all the ones I've used PostNuke and Mambo seem way to complex for my l-users I just want on that will let them put in a few lines of text. MAYBE some images. That would be it, if anyone knows a program or any other way I can do it please let me know ASAP
Thank you
Tech-Geek.net is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-16-2005, 10:50 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
Are they going to be able to edit every page? In that case you may have to rearrange the site a little. For instance instead of multiple .htm files for the pages, you should have just one file, index.php, that gets the different pages like index.php?page=pagename.

It's really not that hard. First, you should divide your code into a header and a footer. There's usually a bunch of HTML that goes right up to the content- that's your header. Then all the HTML after the content, that's your footer.

Save those files as header.php and footer.php, and then your index.php can look something like this:
PHP Code:
<?php 
include 'config.php';
include 
'header.php'

if (!
$_GET['page']) {$page 'home';}

$sql "SELECT content FROM pages WHERE title = '$page'";
$result mysql_query($sql$db);
if (
mysql_num_rows($result) == 0)
{
    die(
'Error.');
}
else
{
    
$row mysql_fetch_array($result);
    echo 
$row['content'];
}

include 
'footer.php'
?>
The config.php file is just a standard file where you keep your database username and password.

Set up a database with a table called "Pages" with three fields: ID (primary key), title, and content.

You can still show your pages as .htm files, just put this .htaccess file in the root directory:
Code:
<Files .htaccess>
order allow,deny
deny from all
</Files>

RewriteEngine ON

##### Index Page Rules #####
RewriteRule ^(.*).htm index.php?page=$1

##### Deny .htaccess viewing #####
RewriteRule ^\.htaccess$ - [F]
Now, to let them edit each page, make a directory called "admin" or something and password-protect it with your cpanel. That's where you can put the page where they do the editing. That page can look something like this:
PHP Code:
<?php
include 'path_to_includes/config.php';
if (
$_POST['submitok']) {$submit true;}else{$submit false;}
if (
$_GET['edit']) {$page_to_edit $_GET['edit'];}else{$page_to_edit 'none';} 
if (
$_GET['save'] == 'ok') {$success true;}
?>
<html>
<head>
    <title>Your Control Panel</title>
    <script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
    <script language="javascript" type="text/javascript">
    tinyMCE.init({
        mode : "textareas",
        theme : "advanced",
        plugins : "table, save, advhr, advimage, advlink, emotions, iespell, insertdatetime, preview, zoom, flash, searchreplace, print, contextmenu, paste, directionality, fullscreen",
        theme_advanced_buttons1 : "bold,italic,underline, separator, strikethrough, ,sub,sup,charmap, separator, forecolor,backcolor, separator,justifyleft,justifycenter,justifyright, justifyfull, separator, bullist,numlist,separator, hr, separator, link,unlink, separator, cut,copy,paste",
        
        theme_advanced_buttons2 : "image, anchor, cleanup, separator, undo, redo, separator, tablecontrols, separator, insertdate,inserttime, code, help",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "center",
        theme_advanced_path_location : "bottom",
        extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[style|align|class|id]"
    });
    </script>
</head>
<body bgcolor="#dedede" style="font-family:helvetica;font-size:10pt;">
<form method="post" action="">

<h1 align="center" style="color:navy;font-family:helvetica;">Your Website Control Panel</h1>

<?php

if ( ($submit == false) && ($page_to_edit == 'none') )
{
    echo 
'<div align="center">';
    if (
$success)
    {
        echo 
'<font color="green"><b>';
        echo 
'Page edited successfully!';
        echo 
'</b></font><br /><br />';    
    }
    echo 
'Choose a page to edit:<br /><br />';
    echo 
'<a href="index.php?edit=home">Home</a><br />';
    echo 
'<a href="index.php?edit=tournaments">Tournaments</a><br />';
    echo 
'<a href="index.php?edit=big_pulls">Big pulls</a><br />';
    echo 
'<a href="index.php?edit=photos">Photos</a><br />';
    echo 
'<a href="index.php?edit=contact">Contact</a>';
    echo 
'</div>';
}
elseif ( (!
$submit) && ($page_to_edit != 'none') )
{
    
$sql "SELECT content FROM pages WHERE title = '$page_to_edit'";
    
$result mysql_query($sql$db);
    
$row mysql_fetch_array($result);
?>

<table width="600" align="center">
    <tr>
        <td>
            <textarea style="width:650px;height:375px" name="text">
                <?php echo $row['content']; ?>
            </textarea>
        </td>
    </tr>
</table>

<div align="center">
    <input type="submit" value="Save Changes" /><br /><br />
    <a href="#" onclick="window.location=('index.php')">Cancel Edit</a>    
</div>

<input type="hidden" name="submitok" value="ok" />

</form>



</body>
</html>

<?php
}
elseif (
$submit)
{
    
$title $_GET['edit'];
    
$text $_POST['text'];
    
    
$sql "UPDATE pages SET content = '$text' WHERE title = '$title'";
    
$result mysql_query($sql$db);
    
    if (
$result)
    {
        echo 
'<script>window.location=(\'index.php?save=ok\')</script>';
    }
    else
    {
        echo 
'error.';
        exit;
    }
}

?>
The extra stuff in there is for TinyMCE, you don't have to use that of course, you could use a plain textarea if you want.

I had to do this for this site last week, so I just thought I'd share my code, which I just threw together and is just very basic.
__________________

Please login or register to view this content. Registration is FREE

Last edited by Phaedrus; 09-16-2005 at 10:58 PM..
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 09-17-2005, 12:17 PM
Junior Talker

Posts: 4
Trades: 0
Thank you for your quick reply.

I'm not terribly familiar with PHP etc. I have the HTML Headers footers etc all setup as Includes so it shouldn't be to hard I hope.

Also do you know a easy way to preview a web site in different browsers (like IE for Mac and Safari etc.)

Thank you thank you thank you.
Tech-Geek.net is offline
Reply With Quote
View Public Profile
 
Old 09-18-2005, 02:09 AM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
There's a website that lets you do that, but I forget what it is. Google around and you can probably find it.
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Content Manager
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.90637 seconds with 12 queries