Archive

Archive for October, 2010

Hiding the “Upload” button on SharePoint document library.

October 2, 2010 1 comment

There might be situations where you might need to hide the “upload” button on a SharePoint document library.  For my case I was working with Infopath and I didn’t want my users to have the ability to upload any type of document into the library so I needed to hide the “upload” button.  I still have not found a way using JQuery YET!  But i’m digging into it.  This can be accomplished using SharePoint designer.

Follow these steps to hide the upload button.

1.  Open your site (if your document library is being displayed in a webpart) or open up your document library using SharePoint Designer.  Make sure that within SharePoint Designer the view is set for Split view (Code and Design) so you can see the Code and Design of your SharePoint site.
2.  Click and highlight the ListViewWebPart for your document library in design view, and then “right click” and select “Convert to XSLT Data View.
3.  Your site will re-render in the design view and you will now see the ListViewWebPart converted to a XSLT Data View Web Part with gridlines.
4.  Click and highlight the Upload button on the design view, you will now see the code for the upload button highlighted in the code view.  You should see something like this:

<td class=”ms-toolbar” nowrap=” “>
    <SharePoint:UploadMenu runat=”server” />
</td>

5.  To hide the UploadMenu button all you have to do is add this code in the <td> tag right after nowrap= ” ”

style=”visibility:hidden”

6.  So your final code should look like this.

<td class=”ms-toolbar” nowrap=” ” style=”visability:hidden” />
    <SharePoint:UploadMenu runat=”server” />
</td>

7.  Now you can do this for any other button you would like.
8.  After making the changes you will see the changes re-render and the Design View will reflect the changes.
9.  Save your site in SharePoint Designer, and then go back to your site on SharePoint.
10.  You should now see the Upload button is now hidden. 

Enjoy!

Modifying SharePoint CSS page design without touching the master page

October 1, 2010 Leave a comment

If you ever wanted to make modifications to an already existing SharePoint template CSS but you are to afraid to mess around with the master page or you don’t have access to SharePoint designer you can easily accomplish this by using a Content Editor Web Part on your page along with some CSS.  The good thing about this is you can go wild and crazy and if you don’t like what  you’ve done you can simply delete the Content Editor Web Part and your page is back to its default.  This is also good if you only need to make changes to just one site or maybe the layout of a specific SharePoint Calendar.

A good reference before you start is Heather Solomon’s page: http://www.heathersolomon.com/content/sp07cssreference.htm

She has already done the hard part for us.  On her site she lists all the major CSS styles used in MOSS and WSS and all their attributes.

So to get started:

1.  On the SharePoint site you would like to modify, edit the page and add a Content Editor Webpart to your site.
2.  Next edit the Content Editor Webpart and edit the Source Editor
3.  Inside the Source Editor add your CSS Style tag.

<style type=”css/text”>
</style>

4.  Next say for example you wanted to modify the recycle bin CSS.  On Heathers reference page she shows that the CSS tag for the recycle bin is:  .ms-recyclebin  awsome!  She also lists the attributes that can be changed for this CSS (Background,Width,Border,Padding,Font weight, color,Text decoration).
5.  Say that we want to change the Border width and the border color of the recyle bin.  No problem.  Inside your <style type=”css/text”> tag reference the .ms-recyclebin CSS tag like so.

<style type=”css/text”>
.ms-recyclebin
</style>
 

6.  Next since we are going to be modifying the CSS of the recyclebin’s border we need to inclose these inside {} for the .ms-recyclebin like so:

<style type=”css/text”>
.ms-recyclebin{
border-style:solid;
border-color:red;
}

7.  Here we changed the CSS border style to solide and color for the recyclebin to red.
8.  Apply and save your changes. You should now see that your recyclebin has a solid border and its colored red.

Again there is so many different combinations and changes you can do to your site using CSS.  Using Heather’s page should have all the major CSS styles to modify at will.

Enjoy and happy CSSing!

Dressing up SharePoint external Links

October 1, 2010 1 comment

For those that are interested in dressing up your SharePoint external links on your pages can do so by using a little JQuery code along with the JQuery Library.

1.  First if you haven’t done so already go to http://jquery.com/ and download the latest version of the JQuery library
2,  Next do a google search for the Icon_External_Link.png.  I’ve included a link for it here: http://upload.wikimedia.org/wikipedia/commons/6/64/Icon_External_Link.png
3.  Upload both the JQuery library and the Icon_External_Link.png onto SharePoint.  I uploaded the JQuery libary in a Documents library and the Icon_External_Link.png image into an Image library.
4.  Next on your SharePoint site, edit and add a Content Editor Webpart to your page.
5.  Edit the Source Editor and copy/paste the following JQuery code below into the source editor

<script src=”/Documents/jquery-1.3.2.min.js”></script>

<script>
$(function() {
     $(‘a’).filter(function() {
          return this.hostname && this.hostname !== location.hostname;
          }).after(“<img src=’/PublishingImages/Icon_External_Link.png’ alt=’External Site’ style=’margin-left: 3px;’>”).attr(‘target’,’_blank’);
});
</script>

6.  For the script and image src tags make sure you point those to where you uploaded your JQuery library and the Icon_External_Link.png image.
7.  Apply and save
8.  On your page you should now see the Icon_External_Link.png image next to all the external links that point outside of your SharePoint portal.

Auto Refreshing SharePoint Page

October 1, 2010 Leave a comment

I’ve been asked many times by my clients if its possible to refresh a SharePoint site on a time interval.  Yes it can, and its fairly simply just by using a Content Editor Webpart and some javascript.  Follow the steps below to auto refresh your SharePoint page/site.

1.  Edit your SharePoint site and add a Content Editor Webpart on your page.
2.  Edit the Content Editor Web Part and inside the Source Editor, copy the javascript code below.

<script>
var reloadTimer = null;
var sURL = unescape(window.location.pathname);
function setReloadTime(secs)
{if (arguments.length == 1)
   { if (reloadTimer) clearTimeout(reloadTimer);
       reloadTimer = setTimeout(“setReloadTime()”, Math.ceil(parseFloat(secs)*1000));
   }  
else   { reloadTimer = null;
     window.location=window.location;
     window.location.replace( sURL );
   }
}
setReloadTime(300);

</script>

3.  Set the setReloadTime(x) to x amount of seconds you would like to wait before refresh.

Enjoy!