Definitive navigation code documentation

9 posts by 4 authors in: Forums > CMS Builder
Last Post: June 2, 2011   (RSS)

By ispro - May 10, 2011

I am trying to build a very basic navigational scheme with a horizontal one-level menu bar linked to a side navigation bar for levels two and three. The forum has threads dating back years on the subject of menus, but I can't find any definitive recent code samples. There are references to different parameters for the list viewer, but I can't find any documentation on this either. Any sugestions?

Thanks.

Re: [ispro] Definitive navigation code documentation

By gkornbluth - May 10, 2011

Hi Ispro,

I'm not sure exactly what you're looking for, but it sounds like a bit of the normal newbie frustration that comes with learning any new programming paradigm.

The best advice that I can offer is to mock up the navigation scheme that you want to in HTML. Then, using the code generated by the Code Generator in the admin section of the CMS Builder interface as a guide, start replacing the variables in your HTML code with PHP code.

After you've written some of the code, if you find specific areas that don't work, post that code here and we'll try to help.

There are also a lot of coding examples and hints , along with a pretty extensive beginners tutorial in my CMSB Cookbook http://www.thecmsbcookbook.com that might prove to be helpful.

Above all, don't give up. The result is well worth the learning curve.

Good luck.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Definitive navigation code documentation

By ispro - May 11, 2011

Thank you for your reply. Newbie frustration this is not. I've got two degrees in CompSci, been professionally involved in IT for over thirty years and have been using AM/CMSB for years! The trouble is that the documentation of the navigation code is weak. There is a sub-category tutotrial in the forum that describes how to set up a category/article scheme, as in the cookbook as well. What I was really after was a good description of the pseudo variables like _IsSelected, _isAncestorSelected, etc.

What I was trying to implement was a level 0 horizontal menu bar. When an option in the bar was selected, a left-hand menu bar would display only the levels below the selected node. I did finally finally figure the code out - it goes something like this:

Horizontal bar:

<ul id="navbar">
<?php $selectedCat=""; ?>
<?php foreach($categoryRecords as $category):?>
<?php if(!$category['_hasParent']):?>
<?php echo $category['_listItemStart']; ?>
<?php if($category['_isSelected']){echo "<b>"; $selectedCat=$category['num'];} ?>
<a href="?category=<?php echo $category['num']?>"><?php echo $category['name']; ?></a>
<?php if($category['_isSelected']){echo "</b>";} ?>
<?php echo $category['_listItemEnd']; ?>
<?php endif ?>
<?php endforeach ?>
</ul>

Sidebar:

<ul id="sidebar">

<?php if($selectedCat): ?>
<?php foreach($categoryRecords as $category): ?>
<?php if($category['_isAncestorSelected']):?>
<?php echo $category['_listItemStart']; ?>
<a href="../mt/articlesList.php?category=<?php echo $category['num'] ?>"><?php echo $category['name'] ?></a>
<?php echo $category['_listItemEnd']; ?>
<?php endif ?>
<?php endforeach ?>
<?php endif ?>
</ul>

Re: [ispro] Definitive navigation code documentation

By gkornbluth - May 11, 2011

Sorry ispro,

I didn't mean to offend you.

Glad you got it worked out.

If there are any other details you'd be willing to add, I'd appreciate the lesson.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [Dave] Definitive navigation code documentation

By gkornbluth - May 12, 2011

Hi Dave,

If you'd post the sample viewer template, that would be great.

It's about time I started learning more about this area.

Thanks,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: Definitive navigation code

By rconring - May 15, 2011

I was putting off attempting to understand and implement the catagories menu simply because I did not understand the various getCategories functions but recently it became unavoidable.

Jason pointed me to Dynamic Drive's Smooth Menu as a candidate for a CMSB driven solution and I was surprised at how easy it was to implement.
http://www.dynamicdrive.com/dynamicindex1/ddsmoothmenu.htm

I downloaded and installed the necessary CSS, Javascript and HTML code. Then, I simply replaced the hard coded sample unordered list code with the category fetch loop below:

<div id="smoothmenu1" class="ddsmoothmenu">
<!-- unordered list -->
<ul>
<?php foreach ($categoryRecords as $categoryRecord): ?>
<?php echo $categoryRecord['_listItemStart'] ?>
<a target="<?php echo $categoryRecord['target_frame'] ?>" href="<?php echo $categoryRecord['target_url'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach; ?>
</ul>
<!-- /unordered list -->
<br style="clear: left" />
</div>

The category records contain some extra fields for target frame selection for external URLs, tooltip text, etc. Note that this particular example does not use the CMSB generated link as the target URL but rather a variable in the category record.

Works like a charm and now that I understand it all a little better, I can set it up on any CMSB site in just a few minutes! Hope this helps someone.
Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

Re: [gkornbluth] Definitive navigation code documentation

By Dave - June 2, 2011

Hi Jerry,

Try these files (attached).

Upload categoryList.php to your website root where you want your category viewer page to be. Be sure to update the require_once() line to point to your /cmsAdmin/ folder.

Upload category.ini.php and category.defaultSqlData.php to /cmsAdmin/data/schema/ making sure you don't already have a section by the same name.

Once you've done that, login to your CMS and click on Admin > Section Editors. This will automatically check for new schema files and create the section and import the data.

Next, view the categoryList.php viewer file in your browser. It shows an example of a nested category list created in plain HTML and a nested list created with ul and li tags.

Note, this is the local test file I use so it shows examples of the more advanced features as well.

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

Re: [Dave] Definitive navigation code documentation

By gkornbluth - June 2, 2011

Thanks Dave,

Looks like I know what I'm doing this weekend...

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php