Title:
Click the Compose link to load compose.php (see Figure 13-7) Enter a title and some text for the article When you are done, click Submit New Article You will be taken back to the index page, but there will still be no article The article you just wrote is pending review 459 Chapter 13 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Figure 13-7 How It Works You’re almost there Next, you tackle compose.php, the page where you create new articles First, initialize the variables you are going to be using: Compose Article
Title:
The article ID must be carried over to the transaction page if you are modifying an existing article The following hidden input field will this for you
If you’ve looked around your Web site, you might have noticed that the article you just created doesn’t show up yet That’s because you’ve set up a review system wherein an administrator or moderator must approve an article before it is published to the public view This sort of control is found on many CMSbased sites on the Web and is a good way to keep an eye on quality and duplicate stories Try It Out Reviewing New Articles In this exercise, you’ll create the reviewing system that lets you approve your articles Create pending.php: Next, create reviewarticle.php: Article Review Click the Review link The Review page pending.php loads (see Figure 13-8) with a list of all pending and published articles Right now, there is only one pending article — the one you just wrote Click the article You will be taken to reviewarticle.php It should look similar to Figure 13-9 You have the option to edit, publish, or delete the article Figure 13-8 464 Building a Content Management System Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Figure 13-9 Click the Publish button You will be taken back to pending.php, and the article will now be listed under Published Articles Click the Articles link, and you will be taken back to the index page This time, the article should appear on the page (see Figure 13-10) 465 Chapter 13 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Figure 13-10 How It Works Next comes pending.php: 467 Chapter 13 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com And so ends another exciting day in the CMS saga Stay tuned while we look at your next file, reviewarticle.php This time, you need to use one of the functions in outputfunctions.php, so you include it at the top of your page First, you display the title of the page, and then use the outputStory() function to display the article on the page Article Review And they all lived happily ever after The End Feeling a little déjà vu? Good Try It Out Article Pages So you’ve created an article, reviewed it, and published it Now it’s time to give the public a way to view the article and provide feedback Create viewarticle.php: Now, create comment.php: Add a commentComment:
Go back to the index by clicking the Articles link Click the “Full Story” link below the snippet of the article you want to view The full article should appear, complete with a link to add comments How It Works The first page, viewarticle.php, is very short, yet it illustrates the nature of included files and functions wonderfully As you can see, there is no content displayed directly with viewarticle It simply includes the necessary files and uses two functions to display the article and all of the comments 470 Building a Content Management System Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com You may notice that you don’t worry about the situation in which an article is not passed As it stands, if you load viewarticle.php without the “article” parameter in the URL, you will simply get a page that consists of the site title, search, and a menu (all included in header.php) The rest will be blank If that’s the desired result, then that’s fine You may decide to redirect the user back to the home page if $_GET[‘article’] is empty If you do, don’t forget to include http.php and use redirect() before header.php The next page is comment.php Include the necessary files: Add a comment A simple text area is used to enter a new comment:
Comment:
The next bit deals with the submit button and a hidden field for the article ID This is needed to send the article ID to the next page:Beginning PHP5, Apache and MySQL< /title> 4 06 User Logins, Profiles, and Personalization Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com... User Logins, Profiles, and Personalization Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com ?> Beginning PHP5, Apache and MySQL< /title> ... Profiles, and Personalization Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Finally, create the fifth file, testcookie.php: Beginning PHP5, Apache and MySQL< /title>