We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22683
    • 41 Posts
    Hello, sorry if I often ask.. because I newbie grin


    How do I create a TV that only displays the folder media .. ? Example, the TV As for the image only shows the folder image ..



    Regards,

    Syu11
      • 5340
      • 1,624 Posts
      How do you want to display the folder?
      A list of files in the media folder?
        • 22683
        • 41 Posts
        How do you want to display the folder?
        A list of files in the media folder?

        Like TV for image will show image folder, or TV for file will show files folder.. but i want to create TV whose show media folder.. smiley



        regards,

        Syu11
          • 22683
          • 41 Posts
          Hello, smiley

          I have successfully solve the problem myself .. but I do not know what I do is correct and safe.. grin

          I use MODX 0.9.6.3, and I want make TV for view media folder in manager.. but there is no option in the input type for media..

          First I edit mutate_tmplvars.dynamic.php file and add this script on line 319

          <option value="media" <?php      echo ($content['type']=='media')? "selected='selected'":""; ?>>Media</option>


          Second, add script at tmplvars.inc.php

          case "media": // handles the input of file uploads
          			global $_lang;
          				global $ResourceManagerLoaded;
          				global $content,$use_editor,$which_editor;
          				if (!$ResourceManagerLoaded && !(($content['richtext']==1 || $_GET['a']==4) && $use_editor==1 && $which_editor==3)){ 
          					$field_html .="
          					<script type=\"text/javascript\">
          							var lastImageCtrl;
          							var lastFileCtrl;
          							function OpenServerBrowser(url, width, height ) {
          								var iLeft = (screen.width  - width) / 2 ;
          								var iTop  = (screen.height - height) / 2 ;
          
          								var sOptions = 'toolbar=no,status=no,resizable=yes,dependent=yes' ;
          								sOptions += ',width=' + width ;
          								sOptions += ',height=' + height ;
          								sOptions += ',left=' + iLeft ;
          								sOptions += ',top=' + iTop ;
          
          								var oWindow = window.open( url, 'FCKBrowseWindow', sOptions ) ;
          							}			
          							function BrowseServer(ctrl) {
          								lastImageCtrl = ctrl;
          								var w = screen.width * 0.7;
          								var h = screen.height * 0.7;
          								OpenServerBrowser('".$base_url."manager/media/browser/mcpuk/browser.html?Type=images&Connector=".$base_url."manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=".$base_url."', w, h);
          							}
          							
          							function BrowseFileServer(ctrl) {
          								lastFileCtrl = ctrl;
          								var w = screen.width * 0.7;
          								var h = screen.height * 0.7;
          								OpenServerBrowser('".$base_url."manager/media/browser/mcpuk/browser.html?Type=files&Connector=".$base_url."manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=".$base_url."', w, h);
          							}
          
          							function BrowseMediaServer(ctrl) {
          								lastFileCtrl = ctrl;
          								var w = screen.width * 0.7;
          								var h = screen.height * 0.7;
          								OpenServerBrowser('".$base_url."manager/media/browser/mcpuk/browser.html?Type=media&Connector=".$base_url."manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=".$base_url."', w, h);
          							}
          							
          							function SetUrl(url, width, height, alt){
          								if(lastFileCtrl) {
          									var c = document.mutate[lastFileCtrl];
          									if(c) c.value = url;
          									lastFileCtrl = '';
          								} else if(lastImageCtrl) {
          									var c = document.mutate[lastImageCtrl];
          									if(c) c.value = url;
          									lastImageCtrl = '';
          								} else {
          									return;
          								}
          							}
          					</script>";
          					$ResourceManagerLoaded  = true;					
          				} 
          				$field_html .='<input type="text" id="tv'.$field_name.'" name="tv'.$field_name.'"  value="'.$field_value .'" '.$field_style.' onchange="documentDirty=true;" /> <input type="button" value="'.$_lang['insert'].'" onclick="BrowseMediaServer(\'tv'.$field_name.'\')" />';
          				break;


          And add this function for images and files at tmplvars.inc.php :

          							function BrowseMediaServer(ctrl) {
          								lastFileCtrl = ctrl;
          								var w = screen.width * 0.7;
          								var h = screen.height * 0.7;
          								OpenServerBrowser('".$base_url."manager/media/browser/mcpuk/browser.html?Type=media&Connector=".$base_url."manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=".$base_url."', w, h);
          							}



          This work well for me, but if that is the way that I do wrong or there is a better way .. please let me know .. smiley



          Regards,

          Syu11
            • 3749
            • 24,544 Posts
            You might look into the @DIRECTORY binding, which can be used in a template variable to list all the files from a given directory. The output can be a drop-down list or radio buttons.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 1343 ☆ A M B ☆
              • 2,213 Posts
              If you haven’t already you should file this in jira (http://svn.modxcms.com/jira/) so it gets added to future releases. I could see it being useful down the road.

              AMDbuilder
                Patrick | Server Wrangler
                About Me: Website | Tweets |  MODX Hosting
                • 7231
                • 4,205 Posts
                Quote from: AMDbuilder at Jul 01, 2009, 06:35 PM

                If you haven’t already you should file this in jira (http://svn.modxcms.com/jira/) so it gets added to future releases. I could see it being useful down the road.
                Yes, please do. I have always wondered why media did not have a TV file browser type. Thanks for looking into this.
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 22683
                  • 41 Posts
                  smiley thank you all....




                  Regards,

                  Syu11