Ok, I have most of my CMS done. I have the data being displayed from the database. I also have the code working to create new pages and menu items. However, I am faced with two issues.
1. The menu will not display horizontally. This is not a major issue but would be good for people who use my script to be given that option if they want to modify the template.
2. Each page has an ID that is created in the database. The script creates a new page and tells the database to define a new ID for each page. For example page.php?id=2 This works fine. But, if I go to say page.php?id=2 and then click on the Home button to go back to the index, the home button also inherits the same URL as the page with the ID. I also noticed that any link on the page with the id= defined, also inherits that URL. I am unable to figure it out and was hoping someone here could help.
Here is the page.php code:
This creates the pages defined in the database and also tells nav.php to create a new menu item.
And here is the nav.php
The HTML part of this relies on CSS for the layout. At the moment I have the menu displayed virtically, until I can figure out the horizontal bit
body.php:
Can anyone see where I am going wrong? Any help would be appreciated.
1. The menu will not display horizontally. This is not a major issue but would be good for people who use my script to be given that option if they want to modify the template.
2. Each page has an ID that is created in the database. The script creates a new page and tells the database to define a new ID for each page. For example page.php?id=2 This works fine. But, if I go to say page.php?id=2 and then click on the Home button to go back to the index, the home button also inherits the same URL as the page with the ID. I also noticed that any link on the page with the id= defined, also inherits that URL. I am unable to figure it out and was hoping someone here could help.
Here is the page.php code:
Code:
<?php
/*****************************
*
* Name: osPHPSite
* Version: 0.0.1
* Developer: Dan O'Riordan
* Email: dan@vichost.com
* Copyright (c) 2010 VicHost
* Date: September 2010
* Website: www.osphpsite.com
* Licence: GNU/GPL v3
*
******************************/
include "language/english/english.php";
include "includes/settings.php";
include "includes/version.php";
include "includes/config.php";
include "templates/default/header.tpl";
include "nav.php";
?>
<div class="art-content-layout">
<div class="art-content-layout-row">
<div class="art-layout-cell art-content">
<div class="art-post">
<div class="art-post-body">
<div class="art-post-inner art-article">
<?php
//if no id defined then load the home page.
if(isset($_GET['id'])){
$id = $_GET['id'];
if(!is_numeric($id)){
include "includes/404.php";
exit;
}
database_connect();
$query = "SELECT * from content where id = $id;";
$echo = mysql_error();
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
if ($num_rows == 0) {
include "includes/404.php";;
exit;
}
while ($row = mysql_fetch_assoc($result)) {
$title = $row['title'];
$text = $row['text'];
$description = $row['description'];
$keywords = $row['keywords'];
}
}
include("includes/body.php");
?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include "templates/default/footer.tpl"; ?>
This creates the pages defined in the database and also tells nav.php to create a new menu item.
And here is the nav.php
Code:
<?php
database_connect();
$query = "SELECT * from content
WHERE status = 1
ORDER by position;";
$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$id = $row['id'];
$menutitle = $row['menutitle'];
//if no menu title entered, then use the title.
if ($menutitle == ""){
$menutitle = $row['title'];
}
$startpage = $row['startpage'];
$href = "page.php?id=$id";
if ($startpage == 1) {
$href = "";
}
?>
<ul class="art-vmenu">
<li>
<a href="<?php echo $href; ?>"><span class="l"></span><span class="r"></span><span class="t"><?php echo $menutitle; ?></span></a>
</li>
</ul>
<?php
}
?>
body.php:
Code:
<?php
database_connect();
$navquery = "SELECT * from content
WHERE status = 1
ORDER by position;";
$navresult = mysql_query($navquery);
while ($row = mysql_fetch_assoc($navresult)) {
$navid = $row['id'];
$menutitle = $row['menutitle'];
$startpage = $row['startpage'];
//if no menu title entered, then use the title.
if ($menutitle == ""){
$menutitle = $row['title'];
}
if ($startpage == 1) {
$href = "/";
}else{
$href = "page.php?id=$navid";
}
$startpage = NULL;
} echo $text;
?>
Can anyone see where I am going wrong? Any help would be appreciated.