We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31136
    • 72 Posts
    This is an auto-generated support/comment thread for DropDownTree.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    DropDownTree a method to display DocumentTree in dropdown TV for selection.
      • 6726
      • 7,075 Posts
      Great really !

      I can think of a bunch of things I’ll do with this one smiley
      Will test and report...
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 29774
        • 386 Posts
        Brilliant, I’ve been looking for something like this. Thank you!
          Snippets: GoogleMap | FileDetails | Related Plugin: SSL
          • 33337
          • 3,975 Posts
          Great stuff man, I was thinking to have something similar for sometime ... thanks for nice contribution.

          regards.
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 13825
            • 55 Posts
            Thanks for this snippet, really usefull!

            Made a few changes:

            • Now shows a "Choose..." option at the top of the list
            • Moved the separator so there’s not a blank item at the bottom
            <?php
            /*
            #   Name:    DropDownTree
            #   Version: 1.0.0
            #   Author:  Urique Dertlian ([email protected])
            #   Date:    Oct 4, 2007
            #   Using:   Create TV of kind "DropDown List Menu", feel elements field with string:
                         @EVAL return $modx->runSnippet("DropDownTree",array('doc'=>0));
                         
                         Here "0" is ID of parent document children of which will be displayed in DropDown menu.
            */
            
            if(!function_exists("getItems"))
            {
            	$s="Choose...==''";
             	function getItems($p=0, $l=0)
            	{
            		global $modx,$modx_charset;
            		($modx_charset=='UTF-8') ? $nbsp=chr(0xC2).chr(0xA0) : $nbsp=chr(0xA0);
            		$c=$modx->getDocumentChildren($p);
            		foreach($c as $k)
            		{
            			$out.='||'.str_repeat($nbsp,$l*5).$k['pagetitle']."==".$k['id'];
            			$out.=getItems($k['id'],$l+1);
            		}
            	return $out;
            	}
            }
            return $s.getItems($doc);
            ?>