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: [ispro] Definitive navigation code documentation

By Dave - May 12, 2011

Hi ispro,

You're right, we don't have much documentation for getCategories() and we need to improve that. If you have any additional questions about how that works feel free to post here or email me direct at dave@interactivetools.com.

If you're comfortable with PHP, the comments about getCategories in /lib/viewer_functions.php description the options:



And I have a sample viewer template that shows a couple different implementations. I can attach that if you'd like to see it.

Also, you can see all the available pseudo fields with <?php showme($categoryRecords); ?>.

In any case, it sounds like you've already got it sorted, but feel free to post or email if you have any further questions.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

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: [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