igerard

Content Management System

This tutorial covers how to write a web content management system using PHP. This WCMS (Web Content Management System) will function like Drupal or Joomla. After you read this, then you'll be able to begin to program your own software.

Content Management System Using PHP

A good content management system provides a service which will modify the way you manage your web page. If you have the time, the best method is to program a custom WCMS. If you do that, then you be able to modify it easily.

If you like, you can also use the ready-made content management system packages like Drupal or Joomla. Many web-pages run on Drupal, for example, and it is generally found to be stable. You might find it useful. However, you might also find that the limitations of using a ready-made content management system package lead to issues with your web page management.

You should make sure that your web page host is prepared to support the PHP version you are working with. You also need to ensure that they have good web hosting expertise. You might have to spend a lot of time searching for an experienced PHP web host.

You should try all the major web hosts. The primary major web hosts are generally held to be BlueHost, 1&1, GoDaddy, and HostGator. The best strategy is to look closely at each offering, as it relates to PHP version and MySQL DB limitations.

Content Management System Programming

When it comes to content management system programming you need a code base to start off of. Therefore, you should look at the following code. It is currently being used for a custom content management system in a production environment.

This code will help you to develop your own custom WCMS package by giving you an idea of the code necessary for custom WCMS programming. This sample code I wrote, which is currently powering my production custom content management system, is based on resources off the web.

What You Are Doing with This Code Is the Following:

1. You use the first sentence of the entry as a title for the entry.

2. After that you list all the entries, using the first sentence of each entry as the entry title.

3. You might find this is a good way to organize your app, as it will automatically update the title database entry.

4. When it comes to a WCMS, there is no reason to have a title field in the database which doesn't update.

These titles also update right away when you modify the entry.Therefore, you don't have change a separate database field if you update your entry.

The code which separates out the first sentence in the entry is this part

"<?php $entry_array = explode('.', $entry->content); ?>"

What this does is make an array using all the sentences found in the $entry->content string. The first string found in this array will be the first sentence in the entry.

So when we use the next line

<?php echo ($entry_array[0])."."?>

You are grabbing the first string in the entry array ($entry_array[0]), which has the first sentence in the entry.

With the next line, you are showing the rest of the entry. You do that by selecting the entry string using the substr command.

<p><?php echo substr($entry->content, strlen($entry_array[0])+1)?></a></p></li>

You begin with the start of the string as the character which is found one character after the end of the first sentence or:

strlen($entry_array[0])+1)

Full Code

<?php include "includes/header.php" ?>

<div class="cache">

<h1>JOURNAL</h1>

<ul id="headlines">

<?php foreach ( $results['entries'] as $entry ) { ?>

<?php $entry_array = explode('.', $entry->content); ?>

<li><p><b><?php echo ($entry_array[0])."."?></b></p>

<p><?php echo substr($entry->content, strlen($entry_array[0])+1)?></a></p></li>

<?php } ?>

</ul>

</div>

<?php include "includes/footer.php" ?>

WCMS Software

You should look at developing your own WCMS software, as it will give you the functionality you want. This code example will give you a code base to start off of. You may have to invest in programming the initial software package. However, you will save a great deal of time in the maintenance phase of using the software. That is statistically the most expensive phase of software use.

You may be tempted to use a ready made package such as Joomla, Drupal, or something of that nature. However, you will see that the limitations of using a one-size-fits-all solution will make it more difficult for you to achieve the functionality you want. The time you invest developing your own software package will pay off in the future.