Creating Menus

10 posts by 4 authors in: Forums > CMS Builder
Last Post: November 25, 2009   (RSS)

By Cathy - June 5, 2008

Here is the situation I want to create:

For each sections DETAIL page I want to include:
1) the content for that particular detail record
2) a submenu for that section that pulls all the records for the section.

I have been able to create the template that sort of works. Here's my issue....

If I have these require items:

list($companyRecords, $companyDetails) = getRecords(array(
'tableName' => 'company',
'where' => whereRecordNumberInUrl(1),
'allowSearch' => '0',
));
$companyRecord = $companyRecords[0]; // get first record


The page displays as seen here:
http://www.fametrics.com/test/template2.php?About_Us-3
Where the page content displays fine, BUT the other two pages I have in that section do not show or link in the side navigation. Here's how the other two pages display:
http://www.fametrics.com/test/template2.php?About_the_Firm-1
http://www.fametrics.com/test/template2.php?contact-4

If I change the requires to:

list($companyRecords, $companyDetails) = getRecords(array(
'tableName' => 'company',
'allowSearch' => '0',
));
$companyRecord = $companyRecords[0]; // get first record


... basically just removing the "where" statement, the side navigation WILL include all three records, and their associated page links are correct, but regardless of the link I click on the last record's content (the Contact Page) displays in the page body.

Here's the code for the navigation:

<div class="nav">
<ul>
<li>HOME</li>
<li>COMPANY</li>
<ul>
<?php foreach ($companyRecords as $companyRecord): ?>
<li> &raquo; <a href="<?php echo $companyRecord['_link'] ?>"><?php echo $companyRecord['title'] ?></a></li>
<?php endforeach; ?>
</ul>
<li>OUR SERVICES</li>
<li>EVENTS</li>
<li>SURVEYS</li>
<li>ARTICLES</li>
<li>CONTACT</li>
</ul>
</div>


And here is the code for the content section:

<?php echo $companyRecord['title'] ?>
<?php echo $companyRecord['content'] ?><br/>
<a href="<?php echo $companyDetails['_listPage']; ?>">&lt; Back to list page</a> -
<a href="mailto:?subject=<?php echo thisPageUrl() ?>">Email this Page</a>


The insert codes don't change either either scenario...just the requires code.

As you can see, I am just getting started on all this and links aren't coded, content is generic ,etc. Right now I'm just trying to get a handle on how everything works and works together before I jump in with both feet!

Any suggestions on how to solve this problem? Or better yet, tell me I am overlooking some code that automatically inserts a fully working dynamic menu/submenu! [;)]
__________________________________
Grafix Unlimited

Re: [Cathy] Creating Menus

By Dave - June 5, 2008

Hi Cathy,

Try including 2 sets of viewer code. One to load the selected page and one to list ALL pages for the menu. Try this:

// load selected page
list($companyRecords, $companyDetails) = getRecords(array(
'tableName' => 'company',
'where' => whereRecordNumberInUrl(1),
'allowSearch' => '0',
));
$companyRecord = $companyRecords[0]; // get first record

// load all pages for menu (put this second)
list($companyRecords, $companyDetails) = getRecords(array(
'tableName' => 'company',
'allowSearch' => '0',
));


Give that a try and let me know if it fixes it. If it doesn't we may need to change the name of a $variable, but I think that might do the job.

Hope that helps, let me know how it goes.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Creating Menus

By Cathy - June 5, 2008 - edited: June 5, 2008

Dave,

I inserted/replaced the code and now it's doing the thing where the pages are in the navigation with the correct links, but the page content never changes.

Take a look at:
http://www.fametrics.com/test/template2.php?About_Us-3
And click on some of the side links.

Thoughts? Thanks Dave!
__________________________________
Grafix Unlimited

Re: [Cathy] Creating Menus

By Dave - June 5, 2008

Hi Cathy,

Ok, I think I got it. The menu code is overwriting $companyRecord. Try renaming the variable in the menu code:

<div class="nav">
<ul>
<li>HOME</li>
<li>COMPANY</li>
<ul>
<?php foreach ($companyRecords as $record): ?>
<li> &raquo; <a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></li>
<?php endforeach; ?>
</ul>
<li>OUR SERVICES</li>
<li>EVENTS</li>
<li>SURVEYS</li>
<li>ARTICLES</li>
<li>CONTACT</li>
</ul>
</div>


Let me know if that does it.
Dave Edis - Senior Developer
interactivetools.com

Re: [Cathy] Creating Menus

By tsuluwerks - November 21, 2009

Hi, gang:

I would like to create something similar, though I have set up the CMS Builder differently

All of the site sections and content are in a table called "Navigation". This is to help the client understand where to put new pages for each top-level category (photo attached).

The way that the design is set up, I would like to have the same menu items show up in the bar at the top of the page (see www.financialtoolsfortrades.org/aboutus.php)

This works great for the landing pages. However, once they click through to a secondary page, the submenu items only show the page that you're on (i.e. click through to "contact us").

This is because I'm using a field called "linkname" in the navigation table to create the links.

Is there a way to generate the links to the submenu items dynamically without breaking out the navigation table into five other tables? It would help my client with understanding the heirarchy of the pages as they add in new subpages (the main categories will stay static).

Thanks,
Tracy
Attachments:

navigationimage.jpg 117K

Re: [tsuluwerks] Creating Menus

By Chris - November 24, 2009

Hi Tracy,

Did you get this sorted out? It seems like your submenu items are displaying on your details-about.php page correctly.

Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Creating Menus

By tsuluwerks - November 24, 2009

I found it faster, though not quite as efficient, to set up separate editors and index/detail pages for each section. I'm leveraging includes as much as possible to cut down on future editing time. I'm glad you found this post. It disappeared on me earlier this week.

Re: [tsuluwerks] Creating Menus

By Chris - November 25, 2009

Hi Tracy,

However, once they click through to a secondary page, the submenu items only show the page that you're on (i.e. click through to "contact us").


If you want to reproduce this problem and post the PHP source code for it, I'll see if I can find a solution for you. Otherwise, if you're happy with your alternate solution, keep doing what you're doing! :)
All the best,
Chris

Re: [chris] Creating Menus

By tsuluwerks - November 25, 2009

Thanks, Chris. the entire site is done except for the other issue that I'm having (see post from last night). Thanks for your help!