display category menu in <ul> format
21 posts by 6 authors in: Forums > CMS Builder
Last Post: August 9, 2010 (RSS)
By markr - March 28, 2010
http://www.interactivetools.com/forum/gforum.cgi?post=64259
Re: [markr] display category menu in <ul> format
By Donna - March 29, 2010
Yup, you've got it. One of the code snippets Dave mentioned is specifically for <ul> lists, and will output the <li> tags for you, with the <?php echo $categoryRecord['_listItemStart'] ?> code. Try that and it should work for you. :)
--
support@interactivetools.com
Re: [Donna] display category menu in <ul> format
By markr - April 5, 2010
In my example below, Apple has no children and uses the class "parent".
Orange has children: it needs a different class and a list for the children.
I do not need to go deeper than 1 child.
Example:
<a class="parent" href="#">Apple</a>
<a class="parent withChildren" href="#">Orange</a>
<div class="submenu">
<ul>
<li><a href="#">Blood</a></li>
<li><a href="#">Navel</a></li>
</ul>
</div>
Re: [markr] display category menu in <ul> format
By Dave - April 9, 2010 - edited: May 5, 2010
In v2.03 we added some "pseudo-fields" called _hasParent and _hasChild for doing tests like that. So you can say:
<ul>
<?php foreach ($categoryRecords as $categoryRecord): ?>
<?php echo $categoryRecord['_listItemStart'] ?>
<?php $aClass = ""; ?>
<?php if (!$categoryRecord['_hasParent']) { $aClass .= "parent "; } ?>
<?php if ($categoryRecord['_hasChild']) { $aClass .= "withChildren "; } ?>
<a class="<?php echo $aClass ?>" href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach; ?>
</ul>
Do those help any?
Update: Fixed code typo
interactivetools.com
Re: [Dave] display category menu in <ul> format
By design9 - May 5, 2010
I am trying to accomplish the same structure here for my category menu within the <ul>.
I am getting the following parse error:
Parse error: parse error, unexpected '<' in D:\hosting\member\charlottepar\site1\test\sitemap\index.php on line 225
Here is my code:
<ul>
<?php foreach ($sitemaplistRecords as $record): ?>
<?php echo $record['_listItemStart'] ?>
<?php $aClass = "";
<?php if (!$record['_hasParent']) { $aClass .= "parent "; } ?>
<?php if ($recordd['_hasChild']) { $aClass .= "withChildren "; } ?>
<span class="body"><a class="<?php echo $aClass ?>" href="<?php echo $record['url'] ?>"><?php echo $record['name'] ?></a></span>
<?php echo $record['_listItemEnd'] ?>
<?php endforeach; ?>
</ul>
Can you help me figure what is wrong?
Thanks!
April
Re: [apdance9] display category menu in <ul> format
By Dave - May 5, 2010
There was a typo in the code. Try this:
<?php $aClass = ""; ?>
Let me know if that fixes it.
interactivetools.com
Re: [Dave] display category menu in <ul> format
By design9 - May 5, 2010
I had tried that but then I get undefined index errors:
see page:
http://www.charlotteparent.com/test/sitemap/index.php
Here is my code now:
<ul>
<?php foreach ($sitemaplistRecords as $record): ?>
<?php echo $record['_listItemStart'] ?>
<?php $aClass = ""; ?>
<?php if (!$record['_hasParent']) { $aClass .= "parent "; } ?>
<?php if ($recordd['_hasChild']) { $aClass .= "withChildren "; } ?>
<span class="body"><a class="<?php echo $aClass ?>" href="<?php echo $record['url'] ?>"><?php echo $record['name'] ?></a></span>
<?php echo $record['_listItemEnd'] ?>
<?php endforeach; ?>
</ul>
Thanks!
April
Re: [apdance9] display category menu in <ul> format
By Dave - May 6, 2010
Thanks!
interactivetools.com
Re: [apdance9] display category menu in <ul> format
By rconring - May 6, 2010
list($sitemaplistRecords, $sitemaplistMetaData) = getRecords(array(
Assuming the table sitemaplist is a category menu, you should use:
list($sitemaplistRecords, $sitemaplistSelected) = getCategories(array(
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987