PEAR Articles

  Home arrow PEAR Articles arrow Creating the Main Pages of a PEAR CMS
PEAR ARTICLES

Creating the Main Pages of a PEAR CMS
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-10-29

    Table of Contents:
  • Creating the Main Pages of a PEAR CMS
  • Code Explained
  • More Code
  • Run the Query

  •  
     

    SEARCH CODEWALKERS

    Creating the Main Pages of a PEAR CMS


    (Page 1 of 4 )

    Welcome to the seventh part of a twelve-part series that explains how to build a content management system in PEAR. In this article we will walk through the code that makes up the main page in the CMS. We will also take a look at the second page of the system, called "view," that is responsible for displaying articles in detail.

    Main page

    <?php

    ob_start();

    session_start();

    if(!isset($_SESSION['author_name'])){

    //redirect to login page

    header("location:login.php");

    }

    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/main.dwt.php" codeOutsideHTMLIsLocked="false" -->

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <!-- InstanceBeginEditable name="doctitle" -->

    <title>Untitled Document</title>

    <!-- InstanceEndEditable -->

    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->

    <link href="Templates/pear.css" rel="stylesheet" type="text/css" />

    </head>


    <body>

    <table width="100%" border="0" class="bord">

    <tr class="header1">

    <td colspan="2"><div align="center">Content Management System </div></td>

    </tr>

    <tr>

    <td width="5%" valign="top"><!-- InstanceBeginEditable name="EditRegion4" -->

    <table width="100%" border="0" cellspacing="0" class="navbord">

    <tr>

    <td colspan="2" bgcolor="#FFFFFF">&nbsp;</td>

    </tr>

    <tr>

    <td colspan="2" bgcolor="#0066FF" class="section"><strong>Section</strong></td>

    </tr>

    <tr class="navbord">

    <td class="nav"><a href="logout.php">Logout</a> </td>

    <td><img src="images/user.gif" width="16" height="16" alt="" /></td>

    </tr>

    <tr class="navbord">

    <td colspan="2" class="nav"><a href="main.php">Home</a></td>

    </tr>

    <tr class="navbord">

    <td colspan="2" class="nav"><a href="authors.php">Authors</a></td>

    </tr>



    <?php if($_SESSION['level']=="admin"){?>

    <tr class="navbord">

    <td colspan="2" class="nav"><a href="admin/index.php">Admin</a></td>

    </tr>

    <?php }?>

    </table>



    <!-- InstanceEndEditable --></td>

    <td width="95%" valign="top"><!-- InstanceBeginEditable name="EditRegion3" -->

    <table width="100%" border="0" class="bord">

    <tr>

    <td colspan="2" class="header">&nbsp;</td>

    </tr>

    <tr>

    <td colspan="2" class="header">Read the latest stories from our authors... </td>

    </tr>



    <?php

    include 'db.php';

    include 'connx.php';

    //retrieve the latest 5 stories, include the author names as well. Store the record

    $sql = "SELECT * FROM stories INNER JOIN authors ON stories.author=authors.aid

    order by s_date asc limit 5";

    $res = $db->query($sql);

    if($res){

    while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {

    ?>

    <tr>

    <td colspan="2" class="title">&nbsp;</td>

    </tr>

    <tr>

    <td colspan="2" class="title"><a href="view.php?sid=<?php print $row->sid?>"


    class="title"><?php print $row->title."..."; ?></a></td>

    </tr>

    <tr>

    <td width="18%">&nbsp;</td>

    <td width="82%" class="auth">by:<?php print $row->name ?></td>

    </tr>

     

    <?php

    }//end while

    }// no recs retrieved run else block

    else{

    ?>

     

    <tr>

    <td colspan="2" class="maintxt"><p>No records found</p></td>

    </tr>

    <?php } ?>

    </table>

     




    <!-- InstanceEndEditable --></td>

    </tr>

     

    <tr class="copy">

    <td colspan="2">&copy;2008</td>

    </tr>

    </table>

    </body>

    <!-- InstanceEnd --></html>

    More PEAR Articles Articles
    More By David Web

    blog comments powered by Disqus

    PEAR ARTICLES ARTICLES

    - Installing PEAR
    - PEAR: an Introduction
    - Managing robots.txt using PHP: Generating Dy...
    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning

    Developer Shed Affiliates

     



    © 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap