<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated on Thu, 09 Sep 2010 04:53:58 -0500 -->
<rss version="2.0">
  <channel>    <title>Codeassembly - How to display infinite depth expandable categories using php and javascript</title>
    <link>http://www.codeassembly.com/feed/comments/22</link>
    <description>CodeAssembly - Simplicity is prerequisite for reliability - Comments</description>
    <language>en-us</language>
    <managingEditor>contact@codeassembly.com</managingEditor>
    <webMaster>contact@codeassembly.com</webMaster>
    <generator>RSS Feed Generator</generator>
    <item>
      <title>Ivan</title>
      <description>Thanks, very nice
How can I modify this to get a "select" list with indented "option"s?</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#339</link>
      <pubDate>2010-08-22 09:03:45</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#339</guid>
    </item>
    <item>
      <title>matt</title>
      <description>how dow you remove link from top categories or on all <ul> and link only all <li> like how you did in this example?

Thanks</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#332</link>
      <pubDate>2010-07-06 10:01:15</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#332</guid>
    </item>
    <item>
      <title>cobb</title>
      <description>mate!

I've been looking for something like this for ages.

You've made it so simple to understand. Thanks</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#324</link>
      <pubDate>2010-05-12 14:02:25</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#324</guid>
    </item>
    <item>
      <title>Vassilis</title>
      <description>Hello, nice script. I have already used this script without problems in the past.

Now I'm using the script in a CMS as a menu and I have alternative cookies there. The problem is that every time I click to the menu all the categories that are already expanded, collapse immediately. I tried to change a lot of things to the script but with no luck. 

Can you please help me? Thanks a lot.  </description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#316</link>
      <pubDate>2009-11-18 07:38:14</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#316</guid>
    </item>
    <item>
      <title>Koray</title>
      <description>How can i integrate this menu ?

http://www.smartmenus.org/samples6/style/simple-style-1/

i integrate with this;

 if ($has_childs === false)
{
 //don't print '<ul>' multiple times                             
$has_childs = true;
echo '<ul id="Menu1" class="MM">';
}


But every <ul> echo <ul id="Menu1" class="MM">

how can i do main <ul> like <ul id="Menu1" class="MM"> and submenu <ul> no css, thank your answers..
</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#308</link>
      <pubDate>2010-03-27 19:48:58</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#308</guid>
    </item>
    <item>
      <title>copied</title>
      <description>sorry link is: http://codecanyon.net/item/manage-categories-of-hierarchic-content/77295</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#300</link>
      <pubDate>2010-04-16 02:52:42</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#300</guid>
    </item>
    <item>
      <title>copied</title>
      <description>Hello your code has been stolen and is being sold here: http://codecanyon.net/item/manage-categories-of-hierarchic-content/</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#299</link>
      <pubDate>2010-04-16 02:51:52</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#299</guid>
    </item>
    <item>
      <title>Tester</title>
      <description>Nice !!! Dos anybody know how to display the menu horizontaly?</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#278</link>
      <pubDate>2009-12-20 12:06:26</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#278</guid>
    </item>
    <item>
      <title>Vassilis</title>
      <description>Hello, nice script. I have already used this script without problems in the past.

Now I'm using the script in a CMS as a menu and I have alternative cookies there. The problem is that every time I click to the menu all the categories that are already expanded, collapse immediately. I tried to change a lot of things to the script but with no luck. 

Can you please help me? Thanks a lot.  </description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#271</link>
      <pubDate>2009-11-17 20:55:54</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#271</guid>
    </item>
    <item>
      <title>John phpALD</title>
      <description>This code will show all main categories.
It will also include the main category in the link when a subcategory has been selected.
and it will take care of the white space in the link when a category name has more then one word.

category name is cars and trucks then the link will be:
/cars-and-trucks/

if there is a subcategory in cars and trucks like new trucks
then the link will be:
/cars-and-trucks/new-trucks/


function generate_menu($parent)
{
	$has_childs = false;
	global $menu_array;
	foreach($menu_array as $key => $value)
	{
		if ($value['parent'] == $parent) 
		{			
			if ($has_childs === false)
			{				
				$has_childs = true;
				echo '<ul id="categories">';
			}
			$cat = str_replace(" ", "-", $value['name']); 
				if ($value['parent'] == 0){
				$cat = str_replace(" ", "-", $value['name']);
				}
				if ($value['parent'] > 0){
				$ca = str_replace(" ", "-", $value['name']);
					$selp = "SELECT * FROM `categories` WHERE `id` = '$parent'";
					$queryp=mysql_query($selp);
					while($rowp = mysql_fetch_array($queryp)){
					 $parentca = str_replace(" ", "-", $rowp['1']);
					}
				$cat = $parentca . '/' . $ca;
				}				
			echo '<li><a href="/' . $cat . '/">' . $value['name'] . '</a>';
			generate_menu($key);
			echo '</li>';
		}
	}
	if ($has_childs === true) echo '</ul>';
}

</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#266</link>
      <pubDate>2009-10-10 12:15:55</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#266</guid>
    </item>
    <item>
      <title>yan</title>
      <description>i could not expand the folder ....why?</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#260</link>
      <pubDate>2009-08-13 04:40:15</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#260</guid>
    </item>
    <item>
      <title>Kevin</title>
      <description>Hi, Nice script, but is it possible to return the <ul><li> etc etc instead of echoing it directly in the function?

Please give some info on this! </description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#255</link>
      <pubDate>2009-07-29 12:26:02</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#255</guid>
    </item>
    <item>
      <title>kevin</title>
      <description>Hi,

here is a little mod I made to the script. For those you might be interested..

function generate_menu($parent){
		
		$output = ''; // We will use this instead of echoing values straight into our function

		$has_childs = false;
		
		global $show_menu;
		
		foreach($show_menu as $key => $value){
			if($value['parent_id'] == $parent){
				if($has_childs === false){
					$has_childs = true;
				}
				if($value['parent_id'] == '0'){
					$output .= '<div id='.$value['class_id'].$value['class'].'>';
					$output .= '<div id='.$value['class_id'].$value['style_id'].'>'.$value['title'].'</div>';
					$output .= '<ul id='.$value['class_id'].$value['list_style'].'>';
				}else{
					$output .= '<li><a href="">'.$value['title'].'</a>';
				}
				$output .= generate_menu($key);
				
				$output .= '</li>';
			}
		}
		if($has_childs === true){
			$output .=  '</ul>';
			$output .='</div>';
		}
		return $output;
	}


Also, this one will make your category name a Normal text instead of a link.. 

What i also did is add some fields in the Mysql Table and store my CSS class and ID, then pass them into the array and put then as variables in my HTML elements..</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#254</link>
      <pubDate>2009-07-29 16:23:15</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#254</guid>
    </item>
    <item>
      <title>bobik</title>
      <description>HI, i`m problem with this code in Mozilla, Opera and Explorer 6 and down version. This code is corect in Expolrer 7. Where is error. Please help me.</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#236</link>
      <pubDate>2009-06-04 08:05:30</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#236</guid>
    </item>
    <item>
      <title>Locnav</title>
      <description>i tried the script but it doesn't show the plus and minus images.
does it matter if i'm running the server on windows?</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#226</link>
      <pubDate>2009-04-23 21:10:28</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#226</guid>
    </item>
    <item>
      <title>Daniel</title>
      <description>If you want to display every folder with parent of 0 just replace
			
if ($has_childs === false)
			{
				//don't print '<ul>' multiple times				
				$has_childs = true;
				echo '<ul>';
			}
With

			if ($has_childs === false)
			{
				//don't print '<ul>' multiple times				
				$has_childs = true;
				echo '<ul id="categories">';
			}


And Replace 
<ul id="categories">
<li>Nested menu categories
<?php
generate_menu(0);
?>
</li></ul>

With

<?php 
generate_menu(0);
?></description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#189</link>
      <pubDate>2009-01-04 20:55:09</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#189</guid>
    </item>
    <item>
      <title>rocbar</title>
      <description>Very good script, but the article could be a little more in detail explaining the variable $has_childs = false; in relationship to the $menu_array or the if ($value['parent'] == $parent).  This would be helpfull for a newbee like me. </description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#157</link>
      <pubDate>2008-08-23 23:02:45</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#157</guid>
    </item>
    <item>
      <title>Terry</title>
      <description>Hi, I have downloaded the menu version and am wondering how to implement an image arrow bullet for the parent categories to show there are children  while recursive function sorts down the levels. Can't seem to make it work any thoughts??
thanks Terry</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#153</link>
      <pubDate>2008-08-21 16:33:14</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#153</guid>
    </item>
    <item>
      <title>Ashish</title>
      <description>This is such a wonderful script....It really helps me to show the category tree like site map.
Thanx a lot</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#135</link>
      <pubDate>2008-06-26 08:51:54</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#135</guid>
    </item>
    <item>
      <title>titel</title>
      <description>Hi,

I was reading your article today and this is exactly what I need for the project I'm working on.

One think though, is there any way that the script is aware of the hierarchy when it displaying the URL as well?

I'll jut give you an example. Say we have
Web development - /web-development
 - - Javascript - /web-development/javascript
 - - - - AJAX - /web-development/javascript/ajax

Again, very good article and thanks a lot,
titel</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#129</link>
      <pubDate>2008-06-13 15:17:10</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#129</guid>
    </item>
    <item>
      <title>MacGoerk</title>
      <description>Actually i think this has something to do with the use of a global var.

If you change the function to

generate_menu($parent, $menu_array) {

remove the line "global $menu_array;"

change the inner recursive call to generate_menu($key, $menu_array)

and the initial call to the recursive function to generate_menu(0, $menu_array) where $menu_array is your mysql result set

it will work!
As php SHOULD make use of pointers and call_by_reference, this will indeed result in a slightly higher memory usage. If it isn't this is just ... going to be exponential large if you have a deeply nested structure. However I'll try this way :)

Also, change the mysqli_whatever calls to mysql_whatever, as mysqli is deprecated.

HTH
Mac</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#99</link>
      <pubDate>2008-05-01 14:22:23</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#99</guid>
    </item>
    <item>
      <title>Ken</title>
      <description>Hi, It looks like this script has a bug. I also has problem listing all of the categories. It starts nicely by listing Web development og followed by Php, but then it stops. 

It really seems like the loop does stops when the last sub categori does not contain a new sub. Because if you add a new sub cat. it will be listed.

Ok? Some ideas? </description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#78</link>
      <pubDate>2008-03-05 07:58:50</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#78</guid>
    </item>
    <item>
      <title>Mk</title>
      <description>Hi.  This code is great!  But one problem: I copied the code straight from this page, and it works fine, except for one thing.  I don't want the category names to be linked.  I only want the subcategories to be linked.  In the example displayed on this page, the category names are not linked, and this is how I want it, but when I copied the code, it makes them links.  How do I fix this?

</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#77</link>
      <pubDate>2008-03-21 14:02:43</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#77</guid>
    </item>
    <item>
      <title>Eric</title>
      <description>Hi,

I'm having the same problems as Schalk & Jason whereby only "Web Development" & "Php" are printing.  It stops there.

Can anyone else get this to work?

Thanks</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#71</link>
      <pubDate>2008-03-21 14:02:43</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#71</guid>
    </item>
    <item>
      <title>Stefan</title>
      <description>Hi,

I discovered a problem when using the script in 
combination with prototype.

The fix is simple ...

file:expand.js line:12

-- OLD --
for(i in cookieA)

-- NEW --
for(i=0;i<cookieA.length;i++)


Prototype adds some generic methods so using the "for in"-iteration causes errors.


cheers

Stefan</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#70</link>
      <pubDate>2008-03-21 14:02:43</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#70</guid>
    </item>
    <item>
      <title>Jason</title>
      <description>Hi

Having the same problem as Schalk above - works perfectly on one host but not on another?

Is there a specific PHP module that has to be enabled/installed for this to work?

Regards

Jason
</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#40</link>
      <pubDate>2007-11-26 07:32:42</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#40</guid>
    </item>
    <item>
      <title>Schalk</title>
      <description>Hi,

I have been looking for something like this for ages, thank you so much! I just have one problem, and I'm sure it would just require a little tweaking of some sorts...When the initial parent level (0) is generated, the only 0 level links that is displayed is 'Web Development' with 'PHP" underneath and that's it! Do you know why this is happening, or even better how I can fix it?

Many Thanks in advance Schalk</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#29</link>
      <pubDate>2007-11-09 08:39:34</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#29</guid>
    </item>
    <item>
      <title>kasp3r</title>
      <description>Thank you very much for your article. It helped me a lot! </description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#15</link>
      <pubDate>2007-11-19 08:52:58</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#15</guid>
    </item>
    <item>
      <title>CodeAssembly</title>
      <description>Yes, your observation is correct, I removed the links from top categories, because I don't have those categories on my website, and I don't like putting # on my links.
Thanks.</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#10</link>
      <pubDate>2007-11-19 08:53:44</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#10</guid>
    </item>
    <item>
      <title>Jason</title>
      <description>The css version doesn't seem to function as per your example i.e. the first item in the menu has href link but should be just text?

Hope that makes sense - great tutorial though :-)

Regards

Jason</description>
      <link>http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#8</link>
      <pubDate>2007-10-05 16:02:58</pubDate>
      <guid isPermaLink="true">http://codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript/#8</guid>
    </item>
  </channel></rss>