0

I am trying to modify my SharePoint 2010 site so that when a user navigates to a specific folder within the default "Shared Documents" document library a notification to the user displays describing the folder/file naming convention for that particular folder. I tried adding a content editor to the page but this shows for all folders within the "Shared Documents" library. Is there a way to show this notification for a particular folder or hide it for folders not equal to the desired folder?

Update: I tried saving the following script to a text file, uploading it to my sharepoint site, and then pasting the url to the text file in the CEWP with no result.

<script language="javascript" type="text/javascript">
  var url = window.location.href;
    var rootFolderUrl = getQueryStringParamvalue("RootFolder");
    var folderRelativeUrl = '%2Fsites%2FBusiness%5FArchitecture%2Fbusinesstransformation%2FShared%20Documents%2FTransformation%20Projects';
    if(rootFolderUrl == folderRelativeUrl) {
      alert("Note: Please utilize the MMM-YYYY standard naming convention when adding folders and files.")
    }
</script>
AliG
  • 1
  • 1

1 Answers1

0

Presuming you have added javascript under content editor webpart to display the notification, you just need to check the RootFolder query string parameter of the url of the current page.
SharePoint appends the relative url of the folder under the RootFolder query string parameter of the current page. Your script should read the current url and compare with the relative url of the folder for which you need to show the notification.
The pseudo code would look something like below:-
    var url = window.location.href;
    var rootFolderUrl = getQueryStringParamvalue("RootFolder");
    var folderRelativeUrl = <relative url of the folder for which you want to show the notification>;
    if(rootFolderUrl == folderRelativeUrl) {
      <code to show the notification here.>
    }

Vineet Desai
  • 872
  • 5
  • 16
  • Hello Vineet, Thank you very much for your response. No, I have not yet explored using JavaScript or any additional coding. I simply added a content editor to the page with the text "Note: Please utilize the MMM-YYYY standard naming convention when adding folders and files." Could you please elaborate on how to add the javascript code you mentioned above? – AliG Mar 14 '16 at 00:48
  • Add a content editor webpart,from the ribbon select Format text and edit HTML source and add script inside the text editor. You can follow instructions http://www.nothingbutsharepoint.com/2011/05/09/adding-script-into-a-content-editor-web-part-cewp-in-sharepoint-2010-aspx/. Also I presume you gave included method definition for getQueryStringParamvalue method. If not, it would be on the similar lines as explained -http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript. I would suggest you to decode the uri and then compare it with the folderRelativeUrl. – Vineet Desai Mar 14 '16 at 17:52