Jump to content

How do I build a Content Management System


KDM

Recommended Posts

I've made a site for a client and they like it.  They asked me who does the updates me or them?  So I know they want to make the updates themselves.  Do anyone know the best place I can learn how to create a CMS? I would prefer video tutorials.  Thanks.

Link to comment
Share on other sites

It is quite simple, especially if you have good experience with php. It uses OOP to a small degree. From what I see, he is implementing it all wrong; more just a collection of functions inside a class. Nontheless, good place to start and it's right on topic.

 

The basic logic here is you need to store the data for your current application in a database. Things like categories, page content etc You then create an admin area which allows full control over this. Depending on the complexity of the app, the database could become quite complex in itself. I'd also look at optimal database design (unless the site is already database driven).

Link to comment
Share on other sites

It is quite simple, especially if you have good experience with php. It uses OOP to a small degree. From what I see, he is implementing it all wrong; more just a collection of functions inside a class. Nontheless, good place to start and it's right on topic.

 

The basic logic here is you need to store the data for your current application in a database. Things like categories, page content etc You then create an admin area which allows full control over this. Depending on the complexity of the app, the database could become quite complex in itself. I'd also look at optimal database design (unless the site is already database driven).

 

 

This tutorial is a great start.  The only thing I need to know now is how to implement the ability for a user to add and delete photo's.

Link to comment
Share on other sites

cms.php

<?php

echo "<form enctype='multipart/form-data' action='upload.php' method='POST'>Choose a file to upload: 
              <input name='uploadedfile' type='file' />
              <input type='submit' value='Upload File' />
            </form>";

$buildhtml = "";
$dirpath = "files/"; 
$dlist = opendir($dirpath); 
while ($file = readdir($dlist)) { 
if (!is_dir("$dirpath/$file")) { 
// assuming that all the files are image files
// when admin click the photo, it will delete the photo
$buildhtml .= "<img src=files/$file onClick='unlink(files/$file);'></img><br>"; 
} 
} 
closedir($dlist); 

if (!empty($buildhtml)) {
echo "Files in Storage</strong></u><p>" . $buildhtml . "</p>";
echo "Click on it to download";
} else {
echo "The directory is <strong>empty</strong>! Upload the files by using the form above.";
}

 

upload.php

<?php
// Created by ZulfadlyAshBurn

header('Refresh: 3; URL=index.php');

// you have to create a folder named files and it should have 777 permissions.
$target_path = "files/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
?>

 

show.php

<?PHP
// Created by ZulfadlyAshBurn

$buildhtml = "";
$dirpath = "files/"; 
$dlist = opendir($dirpath); 
while ($file = readdir($dlist)) { 
if (!is_dir("$dirpath/$file")) { 
// assuming that all the files are image files
$buildhtml .= "<img src=files/$file></img><br>"; 
} 
} 
closedir($dlist); 

if (!empty($buildhtml)) {
echo "Files in Storage</strong></u><p>" . $buildhtml . "</p>";
echo "Click on it to download";
} else {
echo "The directory is <strong>empty</strong>!";
}

?>

you may want to put this (show.php) file in the main page.

 

as you can see, the cms i add in unlink for the admin to be able to delete the photo but at the show pg, the viewers are only able to see but not delete. you can secure you cms.php with some mysql and php.

 

Link to comment
Share on other sites

  • 4 months later...
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.