On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • 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.
    • 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
      • Brilliant, I’ve been looking for something like this. Thank you!
          Snippets: GoogleMap | FileDetails | Related Plugin: SSL
        • 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
          • 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 (uriq@uniqs.ru)
            #   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);
            ?>