Tuesday, November 25, 2014

#SharePoint | An "Open with Explorer" tale

Problem:

I started this mini-project saying to myself:
If I work with Firefox, why can't I get "Open with Explorer".



Soon I realized that I was in way over head.
SharePoint's tight coupling to Internet Explorer, on top of security mechanisms of the web, make trying this a bumpy road.
After many attempts failed, I eventually gave up, but not before I defined a workaround, which would allow me to have something similar, not "one-click" but almost...

Solution:

Some post-attempt observations:
- Trying to re-use the "built-in" functionality quickly seems to be a showstopper.
- Trying to call an URL with file:// seems to have worked in the past, but due to new browser security mechanisms, it no longer works

1. Install grease monkey
https://addons.mozilla.org/pt-PT/firefox/addon/greasemonkey/

2. Add a script
Click "New user script..." from the Grease Monkey context menu.

3. Include jQuery
http://stackoverflow.com/questions/859024/how-can-i-use-jquery-in-greasemonkey
Edit the script and in the end, add a few empty lines, then paste the below to start up.

var $ = unsafeWindow.jQuery;


4. Add a button to a website
http://stackoverflow.com/questions/18226598/how-to-add-a-button-dynamically-using-jquery


5. Open the current library in explorer

Now, the catch.
I'm not really starting the explorer window, but I am providing the means to do so.
I return a prompt with the exact UNC path of the library so I can easily copy-paste it into a "win+r" dialog, or in a plain explorer view, previously opened.
It may seem a bit "tweaky", but for me as a developer, I like it.
I mean, if I use other browsers on a day-to-day basis, why should I have to open IE, map a folder, or even browse folder by folder in the file system to do this?

click the new explorer icon

copy the URL

 paste it in a Win+R window

navigate through your current browser URL folder





Full script:


Pros
  • Get a link to the current SharePoint folder on any URL (not just document libraries)
  •  Works on all sites, without any custom code

Cons
  • Local, per browser setting
  • Doesn't open file explorer directly


Other useful links:
https://social.msdn.microsoft.com/Forums/en-US/a926fd9f-ec4c-4fb0-a7a0-8c2da0804f9c/open-with-explorer-in-sharepoint-2010-greyed-out?forum=sharepointgeneralprevious

http://sharepointhannah.wordpress.com/2013/04/26/using-the-open-in-explorer-link-on-sharepoint-2013/

http://sharepoint.stackexchange.com/questions/27319/how-do-i-enable-open-in-explorer

Update:
Moved to CodePlex at https://spdevtools.codeplex.com/

No comments:

Post a Comment