Skip to content

Custom context menu command

Sergey B (Troex Nevelin) edited this page Apr 8, 2016 · 8 revisions

To add a custom command you must follow this steps:

Added from #257

  1. add the name of your custom command on document ready
$().ready(function() {
				var elf = $('#elfinder').elfinder({
					url : 'php/connector.php',
					commands : [
						'custom','open', 'reload', 'home', 'up', 'back', 'forward', 'getfile', 'quicklook', 
						'download', 'rm', 'duplicate', 'rename', 'mkdir', 'mkfile', 'upload', 'copy', 
						'cut', 'paste', 'edit', 'extract', 'archive', 'search', 'info', 'view', 'help', 'resize', 'sort', 'netmount'
					],
					contextmenu : {
						// navbarfolder menu
						navbar : ['open', '|', 'copy', 'cut', 'paste', 'duplicate', '|', 'rm', '|', 'info'],
						// current directory menu
						cwd    : ['reload', 'back', '|', 'upload', 'mkdir', 'mkfile', 'paste', '|', 'sort', '|', 'info'],
						// current directory file menu
						files  : ['getfile', '|', 'custom', 'quicklook', '|', 'download', '|', 'copy', 'cut', 'paste', 'duplicate', '|', 'rm', '|', 'edit', 'rename', 'resize', '|', 'archive', 'extract', '|', 'info']
					},
					
				}).elfinder('instance');
			});
  1. add the command name your language file :
'cmdcustom'      : 'Custom command',
  1. create a custom command file(you can copy an existing command from source) and include it in your main html
elFinder.prototype.commands.custom= function() {
          this.exec = function(hashes) {
                //implement what the custom command should do here
          }
}
  1. add a css rule for your command. It should be:
.elfinder-button-icon-custom{ //css here }
Clone this wiki locally