A Flash Developer Resource Site

Results 1 to 20 of 20

Thread: CMS Tutorial

  1. #1
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016

    CMS Tutorial

    Okay, as a follow on from the last one, I decided to revisit the simple CMS system as I've been getting more and more enquiries about it and the files on that thread no longer exist.

    I'm starting from scratch so you can ignore the previous CMS thread

    I decided, I'm more likely to be interested in completing the project if it is something I will use so I have opted for creating something for one of my affiliate sites. In my example, the CMS is used for a casino and poker affiliate site but its uses stretch far beyond that.

    Analysis
    Okay, first of all, we ask ourselves why we need a CMS system. With the ability to edit files using a web control panel, I have enough knowledge to edit my site from any computer in the world with an Internet connection but this project is for someone else to create and publish content knowing only a small amount of HTML / Javascript etc. So the first thing I am going to do is plan the best way for this to work.

    Design
    I have decided that instead of doing a CMS system page by page, it would be useful to be able to reuse certain aspects of content. For example, if we take the following 3 pages and the components that make up the page:

    Page 1 - All about 32 Red Casino
    32 red casino review
    32 red bonus scheme
    32 red software
    32 red promotions

    Page 2 - Casino Bonuses
    32 red bonus scheme *
    Littlewoods casino bonus scheme
    Intercasino bonus scheme

    Page 3 - Casino Reviews
    Littlewoods Review
    Intercasino Review
    32 Red casino review *

    As can be seen by the pages flagged with the blue star, these 'paragraphs' occur more than once so instead of duplicating the data, I want to be able to have it sit in one place and be able for it to be displayed on more than one page.

    Because of this, I decided that I wanted the data to be seperate components viewable by linking pieces together to form pages, therefore my first table would be these seperate components, hereby known as 'paragraphs'.

    Part one - Paragraphs
    The first table contains a unique identifier (primary key), a title and the content. To create this table, run the following SQL in your database:

    Code:
    CREATE TABLE `para` (
      `paraId` int(11) NOT NULL auto_increment,
      `paraTitle` varchar(100) default NULL,
      `paraContent` blob,
      PRIMARY KEY  (`paraId`)
    ) TYPE=MyISAM AUTO_INCREMENT=7 ;
    then, I create a simple form which accepts a title and the content and use the following MYSQL code to insert the data into a table called 'para'.

    Code:
    $connection = mysql_connect($host, $user, $password) or die ("can't connect".mysql_error());
    $db = mysql_select_db($database, $connection) or die ("can't connect to database");
    $query = "INSERT INTO para (paraTitle, paraContent) VALUES ('$paraTitle', '$paraContent')";
    mysql_query($query);// or die(mysql_error());
    mysql_close();
    I'll post the files for this shortly. Feel free to ask questions as we go along.
    Last edited by RazoRmedia; 03-14-2005 at 06:04 AM.

  2. #2
    Harry Tuttle phantomflanflinger's Avatar
    Join Date
    Aug 2001
    Location
    Somewhere in the 20th Century...
    Posts
    387
    Nice that this has come back from the dead.I'll make some input when you post the files.

    Bear in mind you can have a CMS without MySQL. PHP can edit any HTML file.
    We're all in it together

  3. #3
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016
    nice to see you back phantom.

    As he states, no mysql database is needed. For this tutorial, I am using a database but I will also try and complete the CMS use datafiles (text files) as well.

  4. #4
    Senior Member Vincent26381's Avatar
    Join Date
    Feb 2003
    Location
    The Netherlands
    Posts
    833

    Re: CMS Tutorial

    Not to flame, but a few points:

    `paraId` int(11) NOT NULL auto_increment Id's won't be negative, by using UNSIGNED your length can be smaller.

    `paraContent` blob Why blob, are you planning on storing Binair data?

    $query = "INSERT INTO para (paraTitle, paraContent) VALUES ('$paraTitle', '$paraContent')";

    Where do $paraTitle and $paraContent come from? If they come from a posted form is should be $_POST['paraContent'] and the values should be escaped (addslashes / mysql_escape_string) to prevent mysql injection.
    Vincent
    SWIS BV

    Last edited by Markp.com on 07-23-2003 at 02:25 AM

  5. #5
    Harry Tuttle phantomflanflinger's Avatar
    Join Date
    Aug 2001
    Location
    Somewhere in the 20th Century...
    Posts
    387
    You're right but give Brucey a chance to post the damn files, love.

    It's chamone.
    We're all in it together

  6. #6
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016
    Thanks Vincent, I'm not the greatest php programmer in the world so I'll take your comments onboard.

  7. #7
    He has risen! lefteyewilly's Avatar
    Join Date
    Mar 2001
    Posts
    2,595
    Do you need Linux to write PHP? I'm only familiar with ASP. What about MySQL? Again, all i know is Access????

  8. #8
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016
    PHP can use access and as its open source, it can run on various platforms.

    I will be using PHP and a mysql database but the fundamentals are there if you wish to apply them using ASP and an access database, only the syntax will change.

  9. #9
    Harry Tuttle phantomflanflinger's Avatar
    Join Date
    Aug 2001
    Location
    Somewhere in the 20th Century...
    Posts
    387
    Originally posted by lefteyewilly
    Do you need Linux to write PHP? I'm only familiar with ASP. What about MySQL? Again, all i know is Access????
    You need a Linux server to run it properly and bench-test it. But you can write it in Notepad!

    I'd learn PHP if I were you. For a Web designer, it is the most important scripting language to learn. And you can call me Susan if it isn't so.
    We're all in it together

  10. #10
    He has risen! lefteyewilly's Avatar
    Join Date
    Mar 2001
    Posts
    2,595
    Originally posted by phantomflanflinger
    You need a Linux server to run it properly and bench-test it. But you can write it in Notepad!

    I'd learn PHP if I were you. For a Web designer, it is the most important scripting language to learn. And you can call me Susan if it isn't so.
    So to test locally on my own harddrive, I'd have to have linux...correct? I don't have a remote server anywhere to test this.

    crap!?

  11. #11
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016
    you should be okay using PWS or IIS.

    You could also try using foxserv. I've never used it personally but a colleague does.

  12. #12
    Harry Tuttle phantomflanflinger's Avatar
    Join Date
    Aug 2001
    Location
    Somewhere in the 20th Century...
    Posts
    387
    There's no substitute for testing PHP/MySQL work on a live Linux server.

    Linux servers with PHP/MySQL are tuppence a foot. In fact you can get some free hosting with it.
    We're all in it together

  13. #13
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016
    For a small yearly fee, I use www.namehog.net

  14. #14
    Allan Jardine
    Join Date
    Dec 2000
    Location
    Turtle hunting
    Posts
    192
    PHP will run quite happily on Apache for Windows, or IIS for Windows. Apache, like PHP, is free, which is why they tend to go together - as is Linux, again, why they all go together.

    You certainly don't need Linux to run PHP...

    Allan

  15. #15
    Modding with Class JabezStone's Avatar
    Join Date
    Aug 2000
    Location
    Grand Rapids, MI
    Posts
    2,008
    For a complete, hassle-free installation of Apache/PHP/MySQL on your windows box... I really recommend http://www.wampserver.com

    It's pretty flawless.

    Good stuff, Bruce... right along with you, here.

    <cough>part2 of affiliate stuff</cough>

  16. #16
    He has risen! lefteyewilly's Avatar
    Join Date
    Mar 2001
    Posts
    2,595
    Thanks guys...i'll see what option works best for me from your suggestions, cause I want to be able to follow this tut.


    tuppence a foot
    Is this 'Deadwood' talk? Does it mean cheap?
    Last edited by lefteyewilly; 03-21-2005 at 06:41 PM.

  17. #17
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016
    okay, heres the first part

    part 2 - The paragraphs section

    The zip file attached contains the following files:

    • createPara.htm - This is a simple form which lets the user input a paragraph title and the paragraph content.
    • addParatoDB.php - This is immediately called after createPara.htm, it adds the information in the form to the database. As the paraId is autoincrement, this is never passed and instead is incremented in the DB when a new record is added.
    • editPara.php - retrieves all the current paragraphs and displays them together on a page with the option of choosing one to edit. This simply displays a list of all the paragraph titles and a button for the user to edit or delete the respective paragraph. The 'edit' button points at changePara.php?id=xx where 'xx' is the id of the paragraph to be edited and the delete button points at deletePara.php?id=xx where 'xx' is the id of the paragraph to be deleted.
    • changePara.php - this page returns the information held in the database and returns it in a form (just a couple of textboxes really. it lets you update a paragraph using a form similar to the createPara.htm page but with the chosen paragraph already in the form.
    • updatePara.php - this updates the changed paragraph as amended by the user in changePara.php
    • deletePara.php - this delete the chosen paragraph as chosen in editPara.php


    The only thing missing here is the file with all the connection strings in to the database, this is needed to be added if youu wish these files to work.

    Any questions, please feel free to post.
    Attached Files Attached Files

  18. #18
    Harry Tuttle phantomflanflinger's Avatar
    Join Date
    Aug 2001
    Location
    Somewhere in the 20th Century...
    Posts
    387
    Nice job. I'll be back next week about this.
    We're all in it together

  19. #19
    Senior Member RazoRmedia's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    3,016
    please feel free to post comments or improvements. I'm not a great php programmer and anyones comments are welcomed.

  20. #20
    Harry Tuttle phantomflanflinger's Avatar
    Join Date
    Aug 2001
    Location
    Somewhere in the 20th Century...
    Posts
    387
    All the sane people have forgotten about this, but not me.

    I'll do something on this this Summer. It's not as simple as bench-testing a fla, this caper.
    We're all in it together

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center