Definitive navigation code documentation
9 posts by 4 authors in: Forums > CMS Builder
Last Post: June 2, 2011 (RSS)
By ispro - May 10, 2011
Thanks.
Re: [ispro] Definitive navigation code documentation
By gkornbluth - May 10, 2011
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
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
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
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
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
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!
interactivetools.com
Re: [Dave] Definitive navigation code documentation
By gkornbluth - May 12, 2011
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
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
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.
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987
Re: [gkornbluth] Definitive navigation code documentation
By Dave - June 2, 2011
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.
interactivetools.com
Re: [Dave] Definitive navigation code documentation
By gkornbluth - June 2, 2011
Looks like I know what I'm doing this weekend...
Jerry
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php