SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Nov 29, 2009, 07:54 #1
- Join Date
- Feb 2009
- Posts
- 1,006
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Newbie: Help on generating html ul
I'm not getting the logic, can anyone help me out? With this code:
PHP Code:echo '<ul class="subCategorias">';
foreach ($arrMenu as $subcategorias)
{
echo '<li>';
echo anchor( base_url() . 'c_categoria/seccao/' . $subcategorias[$strParentIdKey] . '/' . $subcategorias[$strIdKey] . '/',$subcategorias[$strNameKey]),$strNL;
echo '</li>';
if(!empty($subcategorias[$strChildKey]))
{
if (isset($arraySegmento[4]) and $arraySegmento[4]==6)
{
echo '<ul class="subSubCategorias">';
foreach ($subcategorias[$strChildKey] as $subsubcategorias)
{
echo '<li>';
echo anchor( base_url() . 'c_categoria/seccao/1/' . $subsubcategorias[$strParentIdKey] . '/' . $subsubcategorias[$strIdKey] . '/',$subsubcategorias[$strNameKey]),$strNL;
echo '</li>';
}
echo '</ul>';
}
}
}
HTML Code:<ul> <li>cat-1</li> <li>cat-2</li> <li>cat-3</li> <ul> <li>subcat-1</li> <li>subcat-2</li> <li>subcat-3</li> </ul> </ul>
HTML Code:<ul> <li>cat-1</li> <li>cat-2</li> <li>cat-3</li> </ul> <ul> <li>subcat-1</li> <li>subcat-2</li> <li>subcat-3</li> </ul>
Regards,
Márcio
-
Nov 29, 2009, 08:04 #2
- Join Date
- Oct 2009
- Posts
- 1,852
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Just put one foreach loop after another, not inside
But it looks kinda unusual, and your first variant makes more sense
-
Nov 29, 2009, 08:08 #3
- Join Date
- Feb 2009
- Posts
- 1,006
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi, thanks for your reply,
What first variant are you referring to?
[update]
If you are referring to the first <html> snipped code posted, then I must say I agree.
But, given that structure, can we use css to put both ul elements side by side, at the same height? Something like:
item1 subitem1
item2 subitem2
item3 subitem3
?
[/update]
Regards,
Márcio
-
Nov 29, 2009, 08:21 #4
- Join Date
- Oct 2009
- Posts
- 1,852
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
First of all we need more detailed example.
Which subcategory belongs to which category?
From first snippet it looks that all subs belongs to cat-3.
-
Nov 29, 2009, 08:42 #5
- Join Date
- Feb 2009
- Posts
- 1,006
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The categories and subcategories are dynamic, hence, I can never tell where/ /or/if each category will have subcategories inside. I believe.
My question is more css related the php related. I will post my question on the css side of things.
Thanks for your reply on this,
Márcio
-
Nov 29, 2009, 08:47 #6
- Join Date
- Feb 2009
- Location
- Scotland
- Posts
- 33
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You may want to check out the following thread, where I asked a similar question a few days ago - http://www.sitepoint.com/forums/showthread.php?t=648427
Bookmarks