Navigation

12 posts by 2 authors in: Forums > CMS Builder
Last Post: September 5, 2009   (RSS)

By dsternalski - August 27, 2009

Hi,

I have a problem with the navigation working correctly. I have four main navigation items and two of them have secondary navigation. The navigation is a drop down hover build using CSS. I have created the code so that the CMS can name both the main and secondary navigation items rather than having to hard code the main navigation. This navigation is also included in the page using an include.

when i select the on of the main navigation items that has a secondary navigation under it, the page loads correctly, but the seondary navigation then doesn't display on the hover and it is meant to.

Also, when i select one of the secondary navigation, the page again loads correctly except that the main navigation that it is situated under disappears off the site until you click onto another page.

Below is the code that I wrote for the navigation (which worked on another site I was developing).

<div class="line"></div>
<img class="logo" src="images/logo.jpg" alt="Janizm" />
<div id="topNav">
<ul>
<li><a href="index.php">
<?php foreach ($indexRecords as $record): ?>
<?php echo $record['navigation_name'] ?>
<?php endforeach; ?>
</a></li>
<li>
<?php foreach ($galleryRecords as $record): ?>
<?php if ($record['depth'] == 0): ?>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['navigation_name'] ?></a>
<?php elseif ($record['depth'] == 1): ?>
<ul>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['navigation_name'] ?></a></li>
</ul>
<?php endif ?>
<?php endforeach; ?>
</li>
<li>
<?php foreach ($linksRecords as $record): ?>
<?php if ($record['depth'] == 0): ?>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['navigation_name'] ?></a>
<?php elseif ($record['depth'] == 1): ?>
<ul>
<li><a href="<?php echo $linksRecords['_link'] ?>"><?php echo $record['navigation_name'] ?></a></li>
</ul>
<?php endif ?>
<?php endforeach; ?>
</li>
<li><a href="contact.php">
<?php foreach ($contactRecords as $record): ?>
<?php echo $record['navigation_name'] ?>
<?php endforeach; ?>
</a></li>
</ul>
</div>

Suggestions would be very much appriciated.

Re: [dsternalski] Navigation

By Chris - August 27, 2009

Hi dsternalski,


The navigation is a drop down hover build using CSS.


If things are disappearing on you, I'm guessing the problem has to do with a combination of how the page is structured and how your dynamic drop-down hover code works. Do you have a URL I can check out to see the problem in action?
All the best,
Chris

Re: [chris] Navigation

By dsternalski - August 29, 2009

hi,

thanks for you replay. unfortunatly it's not loaded up onto any servers at the moment, however i did get the navigation to work! the only problem that i now have is that when i click on the first or second navigation (of a page that has a second navigation), the page now displays both pages on one.

the navigation code:

<?php
list($navigation, $navigationMetaData) = getRecords(array(
'tableName' => 'gallery',
//'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$navigation = @$navigationRecord[0]; // get first record;
?>
<?php echo $navigation ?>
<div class="line"></div>
<?php //new dBug ($innerRecord) ?>
<img class="logo" src="images/logo.jpg" alt="Janizm" />
<div id="topNav">
<ul>
<li><a href="index.php">
<?php foreach ($indexRecords as $record): ?>
<?php echo $record['navigation_name'] ?>
<?php endforeach; ?>
</a></li>
<li>
<?php foreach ($galleryRecords as $record): ?>
<?php if ($record['depth'] == 0): ?>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['navigation_name'] ?></a>
<?php foreach ($galleryRecords as $innerRecord): ?>
<ul>
<?php if ($innerRecord['parentNum'] == $record['num']): ?>
<li><a href="<?php echo $innerRecord['_link'] ?>"><?php echo $innerRecord['navigation_name'] ?></a></li>
<?php endif ?>
</ul>
<?php endforeach; ?>
<?php endif ?>
<?php endforeach; ?>
</li>
<li>
<?php foreach ($linksRecords as $record): ?>
<?php if ($record['depth'] == 0): ?>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['navigation_name'] ?></a>
<?php foreach ($linksRecords as $innerRecord): ?>
<ul>
<?php if ($innerRecord['parentNum'] == $record['num']): ?>
<li><a href="<?php echo $innerRecord['_link'] ?>"><?php echo $innerRecord['navigation_name'] ?></a></li>
<?php endif ?>
</ul>
<?php endforeach; ?>
<?php endif ?>
<?php endforeach; ?>
</li>
<li><a href="contact.php">
<?php foreach ($contactRecords as $record): ?>
<?php echo $record['navigation_name'] ?>
<?php endforeach; ?>
</a></li>
</ul>
</div>
<?php ?>

the gallery code:

<?php header('Content-type: text/html; charset=utf-8');

require_once "C:/Users/Dani/Documents/xampp-win32-1.6.6a/xampp/htdocs/janizm/cmsAdmin/lib/viewer_functions.php";
include_once "C:/Users/Dani/Documents/xampp-win32-1.6.6a/xampp/htdocs/dBug/dBug.php";

list($indexRecords, $indexMetaData) = getRecords(array(
'tableName' => 'index',
));
list($galleryRecords, $galleryMetaData) = getRecords(array(
'tableName' => 'gallery',
//'where' => whereRecordNumberInUrl(1),
//'limit' => '1',
));
$galleryRecord = @$galleryRecords[0]; // get first record
list($linksRecords, $linksMetaData) = getRecords(array(
'tableName' => 'links',
));
list($contactRecords, $contactMetaData) = getRecords(array(
'tableName' => 'contact',
));
// show error message if no matching record is found
if (!$galleryRecord) {
print "Record not found!";
exit;
}

?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/janizm.css" rel="stylesheet" type="text/css" />
<title><?php foreach ($galleryRecords as $record): ?><?php echo $record['name'] ?><?php endforeach ?></title>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<body>
<div class="container">
<?php
include("navigation/navigation.php");
?>
<?php foreach ($galleryRecords as $record): ?>
<div class="mainText">
<?php echo $record['content'] ?>
<div class="flashContent">
<script language="JavaScript" type="text/javascript">
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '630',
'height', '420',
'src', 'slideshowpro',
'quality', 'high',
'pluginspage', 'http://www.adobe.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'slideshowpro',
'bgcolor', '#ffffff',
'name', 'slideshowpro',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', 'slideshowpro',
'salign', '',
'FlashVars','xmlfile=http://localhost/janizm/images.xml.php?recordNum=<?php echo $record ['num']?>'
);
</script>
</div>
</div>
<?php endforeach ?>
<br class="clearBoth" />
</div>
</body>
</html>

Re: [dsternalski] Navigation

By Chris - August 29, 2009

Hi dsternalski,

Wow, that's some complicated code you've got going on there.

I think I figured out what you mean by "the page now displays both pages on one".

Here's the part of your Gallery Detail page where you get records from the server:

list($galleryRecords, $galleryMetaData) = getRecords(array(
'tableName' => 'gallery',
//'where' => whereRecordNumberInUrl(1),
//'limit' => '1',
));
$galleryRecord = @$galleryRecords[0]; // get first record


I notice that you've commented out the code which selects a single record based on the query string. I'm assuming you're doing this so that you can use the same Record Set to list all the galleries in your Navigation Include. Unfortunately, this approach leaves your single record variable ($galleryRecord) set to the first record in the section every time (and not to the record the user wants to view.)

Furthermore, the code on your Gallery Detail page uses foreach statements to loop over all the records in $galleryRecords (which is all the records in that section,) displaying each of them instead of a single record:

<title><?php foreach ($galleryRecords as $record): ?><?php echo $record['name'] ?><?php endforeach ?></title>
...
<?php foreach ($galleryRecords as $record): ?>
...
<?php echo $record['content'] ?>
...
'FlashVars','xmlfile=http://localhost/janizm/images.xml.php?recordNum=<?php echo $record ['num']?>'
...
<?php endforeach ?>


Let's simplify things.

First off, let's isolate your Navigation Include so that it uses its own variables instead of sharing variables with the rest of your pages. We can do this by choosing unique variable names. Below, I've chosen the names $allIndexRecords, $allGalleryRecords, $allLinksRecords, and $allContactRecords.

<?php

list($allIndexRecords, $indexMetaData) = getRecords(array(
'tableName' => 'index'
));
list($allGalleryRecords, $galleryMetaData) = getRecords(array(
'tableName' => 'gallery'
));
list($allLinksRecords, $linksMetaData) = getRecords(array(
'tableName' => 'links',
));
list($allContactRecords, $contactMetaData) = getRecords(array(
'tableName' => 'contact',
));
?>
<ul>
...


I think we can omit your $navigation variable, right? That looks like it was just there for testing.

Let's leave those navigation lists flat for now and we can come back to making them properly indented after everything else is working:

...
<ul>
<?php foreach ($allIndexRecords as $record): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['navigation_name'] ?></a></li>
<?php endforeach; ?>
<?php foreach ($allGalleryRecords as $record): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['navigation_name'] ?></a></li>
<?php endforeach; ?>
<?php foreach ($allLinksRecords as $record): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['navigation_name'] ?></a></li>
<?php endforeach; ?>
<?php foreach ($allContactRecords as $record): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['navigation_name'] ?></a></li>
<?php endforeach; ?>
</ul>


Now that your Navigation Include works, let's readdress your Gallery Detail page, which only needs a single getRecords() call and should not have a single foreach statement in it:

list($galleryRecords, $galleryMetaData) = getRecords(array(
'tableName' => 'gallery',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$record = @$galleryRecords[0]; // get first record
...
<title><?php echo $record['name'] ?></title>
...
<?php include("navigation/navigation.php"); ?>
...
<?php echo $record['content'] ?>
...
'FlashVars','xmlfile=http://localhost/janizm/images.xml.php?recordNum=<?php echo $record['num'] ?>'
...


I hope this helps you! Please let us know when you've got that working or if you run into any trouble.

P.S. It might be easier for people to help you if you use forum tags around your code, or upload your code as attachment(s). Reading unindented code can be difficult.
All the best,
Chris

Re: [chris] Navigation

By dsternalski - September 1, 2009

hi, thanks again for your reply. i tried the code that you sent, and it still doesn't seem to fix the problem.

Re: [dsternalski] Navigation

By Chris - September 1, 2009

Hi dsternalski,

Can you post your current code (as forum attachments please, they're much easier to read with indentation) and maybe provide a link to an example page where I can see what the problem is?
All the best,
Chris

Re: [chris] Navigation

By dsternalski - September 2, 2009 - edited: September 2, 2009

hi,

Please find the code for both the navigation and the Gallery page(s) attached.

I am in the process of sorting out somewhere to upload the test site too, so i should have a link soon, so i have attached a screen shot to explain.

As you know the navigation is built in CSS and is flyout rollover navigation. Gallery is meant to situate under gallery 22 (the same with both the links buttons in the navigation).

However, when you click on the gallery link, it displays the correct url as does gallery 22, but the content on the page no matter the url is the same.

Re: [chris] Navigation

By dsternalski - September 4, 2009

hi thank you! that worked!

how do i now get the navigation to work the way that i want it to with the secondary navigation as a selection on the main navigation like on http://www.web--templates.org/menus/css-flyout-menu.html (the actual navigation function)?

thank you again!

Re: [dsternalski] Navigation

By Chris - September 4, 2009

Hi dsternalski,

I'm afraid I've never used Deluxe Menu. Can you provide an example of how to use it with static content, and I can hopefully show you how to get CMSb to populate it with your data?
All the best,
Chris