Custom file actions

You can easily add custom options inside the "Open with.." file contextual menu. Here is a step by step guide:

  1. Make a copy of "/path-to-WebFileShare/customizables/custom_actions/_example" inside the same folder and rename it to "my-action" (you are free to name the folder as you wish). (Writing an underscore in front of the folder's name disables the option.)
  2. Open the file "my-action/app.php" in a PHP editor:
  • Rename the class to "custom_my-action". (Note that this depends on the folder's name.)
  • Edit the code according to your requirements:

Define the text that will be displayed for the contextual menu option:

$this->JSconfig['title']

Define the URL of the contextual menu option's icon:

$this->JSconfig['icon']

Make the option open a popup window with the specified size.

$this->JSconfig['popup'] = array(

 "width" => 840,

 "height" => 570

);

When using a popup window, the output of the method "custom_my-action::run()" will be displayed inside the popup. The "$this->data" array can be used to find the file's path:

function run() {

 echo $this->data['filePath'];

}

If you wish to execute a JavaScript function (perhaps making an Ajax call) instead of opening a popup, use this instead:

$this->JSconfig['fn'] = "alert('Option clicked!')";

Add the following option to display the contextual option only for certain filetypes:

 $this->JSconfig['extensions'] => array("txt", "pdf", "doc");

Allow only users with download permissions to see and use this plugin:

 $this->JSconfig['requiredUserPerms'] => array("download");


Misc custom actions:

  • View Office files with Microsoft Office Web Viewer (download)
  • View PDFs and annotate with Crocodoc.com (download)
  • View documents online with Vuzit.com (download)

 

Attached Files
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Name
Email
Security Code Security Code
Related Articles RSS Feed
Adding custom functionality
Viewed 2447 times since Thu, Mar 6, 2014
Counting file downloads
Viewed 3988 times since Thu, Mar 6, 2014
Custom even scripts
Viewed 2606 times since Wed, Nov 22, 2017
Forcing certain file types to download
Viewed 2750 times since Thu, Mar 6, 2014
Calculating MD5 Checksums
Viewed 2695 times since Thu, Mar 6, 2014
Adding links to the menu
Viewed 2565 times since Thu, Mar 6, 2014
Running custom scripts when users perform various actions
Viewed 3439 times since Thu, Mar 6, 2014
Custom CSS
Viewed 1990 times since Wed, Nov 22, 2017
File reference
Viewed 2499 times since Tue, Jun 10, 2014
Automatic Login
Viewed 2375 times since Wed, Nov 22, 2017
MENU