Building a Relational Content Management System in PHP/MySQL - Displaying the Articles (
Page 5 of 5 )
Okay, so now we've reached the fun part, actually displaying the articles for people to read.
Create a file called "index.php":
<?
include("common.php");
$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : '';
$seoname = isset($_REQUEST['seoname']) ? $_REQUEST
['seoname'] : '';
if( !empty($seoname) ){
$seoname = explode("-",$seoname);
$seoname = end($seoname);
}
?>
<table width=100%>
<tr>
<td width=200>
<?
$leftMenu = getPages('parent','0');
foreach($leftMenu as $id=>$page){
echo "<a href='{$page['seoname']}.html'>{$page['title']}
</a><br/>";
}
?>
</td>
<td>
<?
if( !empty($seoname) ){
$page = getPage('seoname',$seoname);
}else{
$page = getPage('id','1');
}
?>
<h1><?=$page['title']?></h1>
<p><?=nl2br($page['body'])?></p>
<?
$kids = getPages('parent',$page['id']);
if( count($kids) > 0 ){
foreach($kids as $id=>$kid){
echo "<a href='{$page['seoname']}-{$kid['seoname']}.html'>
{$kid['title']}</a><br/>";
echo "<p>{$kid['summary']}</p>";
}
}
?>
</td>
</tr>
</table>
Here, we look to see whether we've passed the $seoname variable, and if we have, we split it into an array and grab its last value. This lets us use that as the article id and display the current article. We can build on this system quite easily.
Conclusion
There we have it: a quick, easy to use Relational CMS.
This CMS can be built on pretty easily and quickly, but I wanted to get the basics down here first.
| | Discuss Building a Relational Content Management System in PHP/MySQL | | | | | | | This is a test comment. | | | | | | Hi, first of all thank you for this tutorial. I've just tried your codes but i think... | | | | | | Change:
function buildDropDown($parent,level = 1,$articleId){
To:
function... | | | | | | One more error:
$seoname = isset($_REQUEST['$seoname']) ? $_REQUEST['$seoname'] :... | | | | | | I forgot to mention, it's in index.php | | | | | | When i tried to enter an article, the following error occurred:
Fatal error: Call... | | | | | | Remove this line:
$_POST['akey'] = makeKey(10);
akey no longer gets used in... | | | | | | After i had made the last change, it worked.
Thank you. | | | | | | Thanks for Tutorial. I'm getting an error message saying
Fatal error: Call to... | | | | | | Hi there!
It was a nice tutorial and my hopes were high, but I was disappointed. I... | | | | | | It is possible that sessions in PHP in your case not work. | | | | | | i had the same "server encountered an internal error..."
the problem was a... | | | | | | Originally, I didn't have a line break in the .htaccess for this article.
Must have... | | | | | | Ive read all the above comments and made the necessary changes, but I still have... | | | | | | The header function is touchy. It must be called before anything is sent to the... | | | | | | Hi. I enjoyed your project. Everything works except getting the article itself to... | | | | | | Solution: Turn on (uncomment) mod_rewrite in the httpd.conf file.
Works great. | | | | | | Thank you very much for this tutorial. It works great for me with one exception: ... | | | | | | That's a nice tutorial. thank you. but what about deleting an article | | | | | | Anyone Knows how to use FCKeditor? I tried to do so but I can't. I am new to... | | | | | | I got your tutorial to work after reading all the comments and making that one last... | | | | | | I have just gone thru the tutorial and comments and have some aspects working but,... | | | | | | I am using your Relational CMS Tutorial as the basis of a content management system... | | | | | | I have a different database abstraction layer getting my MySQL commands to be... | | | | | | Hello everybody... someone have the code with the changes?
.. am still have the... | | | | | | Getting a "404" error. Not sure what the problem is, I'm using ubuntu with Apache2;... | | | | | | >>> Post your comment now! | | | | | |
|
 |