8/22/2012

SharePoint 2010 - Create a Calendar View without Hyperlinks

 

This article is one of the many tips in my book, SharePoint 2007 and 2010 Customization for the Site Owner, and presented here as a response to an MSDN forum question. So if this is useful to you… buy the book!

A 2007 version is here and in a lot more detail in my book.

 

We often need a calendar view that is just a "calendar view". I.e. no hyperlinks, just text.

In SharePoint 2010 the data for the calendar is asynchronously loaded using a SharePoint built-in JavaScript function called after the page is loaded. That means that the data we want to change is not yet in the browser when the JavaScript is loaded from within the Content Editor Web Part. To get our code to run at the right time we need to hook into the SharePoint function that loads the calendar items. This is a function named "SP.UI.ApplicationPages.CalendarNotify.$4a".We also need to delay the load of our code, and we can do that with a SharePoint feature named "_spBodyOnLoadFunctionNames.push".

Two Solutions!

Content Editor Web Part

Add a Content Editor Web Part as we have done in many of the other customizations. The problem with this approach is that SharePoint 2010 will no longer treat this page as a view. When this page is displayed you will see two changes:

  • The View dropdown list in the site title area is missing
  • The ribbon will not be displayed when the page is first loaded, but will be displayed when any event item is clicked.

SharePoint Designer

Add the custom JavaScript using SharePoint Designer. The page will then display as an ordinary view with no odd behavior.

I recommend the second approach.

 

Steps - Using SharePoint Designer
  1. Go to the calendar in the browser and create a new view (maybe "Calendar - No Links")
  2. Open your site in SharePoint Designer 2010
  3. Click Lists and Libraries in the Site Objects pane
  4. Click your calendar list and click the new view
  5. In the ribbon click the Advanced Mode link (so you can edit the entire page)
  6. Search for "</WebPartPages:WebPartZone>" and insert a new line just after this tag
    </WebPartPages:WebPartZone>
    your customization goes here (don't type this J )
    </asp:Content>
  7. Add the JavaScript from below
  8. Save your changes in SharePoint Designer
  9. Go to the calendar in a browser, select the new view and confirm that the hyperlinks have been removed

 

Steps - Using a Content Editor Web part
  1. Open Notepad and add the JavaScript from below and save the file (maybe "HideCalendarLinks.txt")
  2. Upload the file to a library (I use a library named CustomziationFiles)
  3. Right-click the new library file, click Properties and copy the URL to the file
  4. Go to the calendar in the browser and create a new view (maybe "Calendar - No Links")
  5. After the new calendar view has been displayed click Site Actions, Edit Page
  6. Add a Content Editor Web Part
  7. Move the new web part below the calendar web part
  8. Edit the web part and paste the URL to the text file uploaded earlier into the Content Link box
  9. Click OK to save the change, then in the Page tab of the ribbon click Stop Editing
  10. Go to the calendar, select the new view and confirm that the hyperlinks have been removed

 

Code to hide the links

Code note!  Prior to service pack 1 you will need to use SP.UI.ApplicationPages.CalendarNotify.$4a while after service page 1 you will need to use SP.UI.ApplicationPages.CalendarNotify.$4b.

<script type="text/javascript">

// TechTrainingNotes.blogspot.com
// Sample code from "SharePoint 2007 and 2010 Customization for the Site Owner"
// ISBN: 978-0982899205
// http://www.amazon.com/dp/0982899203/ref=as_li_ss_til?tag=tectranot-20&camp=213381&creative=390973&linkcode=as4&creativeasin=0982899203&adid=0cc7a0y6fv2nknxyqvff&


// load our function to the delayed load list
_spBodyOnLoadFunctionNames.push('hideCalendarEventLinkIntercept');

// hook into the existing SharePoint calendar load function
function hideCalendarEventLinkIntercept()
{
  var OldCalendarNotify4a = SP.UI.ApplicationPages.CalendarNotify.$4b;
  SP.UI.ApplicationPages.CalendarNotify.$4b = function () 
    {
      OldCalendarNotify4a();
      hideCalendarEventLinks();
    }
}

// hide the hyperlinks
function hideCalendarEventLinks()
{

  // find all DIVs
  var divs = document.getElementsByTagName("DIV");
  for (var i=0; i<divs.length; i++)
  {
    // find calendar item DIVs
    if (divs[i].className.toLowerCase() == "ms-acal-item")
    {
      // find the hyperlink
      var links = divs[i].getElementsByTagName("A");
      if (links.length == 1)
      {
        // replace the hyperlink with text
        links[0].parentNode.innerHTML = links[0].innerHTML
      }
    }

    // find "x more items" links and re-remove links on Expand/Contract
    if (divs[i].className.toLowerCase() == "ms-acal-ctrlitem")
    {
      var links = divs[i].getElementsByTagName("A");
      if (links.length == 1)
      {
        links[0].href = "javascript:hideCalendarEventLinks();void(0);"
      }
    }

  }
}

</script>

 

 

.

8/17/2012

Cincinnati SharePoint User Group Lightning Rounds!

 

6:00 PM 9/6/2012 at MAX Technical Training

http://www.CincinnatiSPUG.org

Lightning Rounds (You can be a speaker too!)

The Cincinnati SPUG September meeting will feature what we call a Lightning Round session where each presenter will have 5 to 15 minutes to present on anything related to SharePoint. We do this just for fun, and as a great way to get people with SharePoint expertise to start speaking at SharePoint events. PowerPoints are optional, five slides or less and just talk about something cool you've done with SharePoint. (We stole the idea from the Columbus SPUG and the Dayton SPUG stole it from us!)

If you are in the Cincinnati area, and would like to try your hand at speaking, let me know. (Post a message below with your email and I'll get back to you. Your reply and email will not be displayed.)

All SharePoint nuts are welcome to attend, even if you are not speaking.

Logo created by Michael Hiles

.

Final Reminder! First Ever Cincinnati PowerShell User Group Meeting 8/28!

 

Tuesday, August 28, 2012, 6:00 PM to 8:00 PM (add it to your calendar NOW!)

It's free! Go here and register NOW!
http://www.meetup.com/TechLife-Cincinnati/events/75092962/
(Registration is not required, but will help us plan for the event, order pizza and spread the word.)

Speaker is scheduled, SWAG is being acquired, people are signing up.

Ed Wilson, the Microsoft Scripting Guy and a well-known scripting expert, will be the kick off speaker for the new Cincinnati PowerShell user group. His topic will be "Using Windows PowerShell 3.0 to manage the remote Windows 8 workstation".

Goodies are on the way from Microsoft Press, O'Reilly, APress and others! Free books, discounts, and other stuff, all to be given away as door prizes. (But I know you are coming to hear Ed speak, not to win door prizes!)

Come prepared to network, talk PowerShell and even volunteer to support this new user group!

 

Spread the word!

Let your coworkers know. Blog and Tweet about it. (#cincypowershell should work)

 

Ed's Topic "Using Windows PowerShell 3.0 to manage the remote Windows 8 workstation"

There are four different ways to manage a remote Windows 8 workstation. The first is to use WMI remoting, the second is to use the computername cmdlets, the third is to use WinRm and Windows PowerShell native remoting, the last way is to use the CIM cmdlets. Each approach has advantages and disadvantages for the network administrator. In this session, I will examine each approach, and provide a checklist of criteria to aid the enterprise network administrator in choosing the appropriate technology for a variety of real world scenarios. This presentation combines live demo’s and interactive discussion to heighten learning.

About the presenter:

Ed Wilson is the Microsoft Scripting Guy and a well-known scripting expert. He writes the daily Hey Scripting Guy! blog. He has also spoken multiple times at TechEd as well as at the Microsoft internal Tech Ready and Geek Ready conferences. He has also spoken at the first SQL Rally conference in Orlando, as well as at numerous SQL Saturday events. He is a Microsoft-certified trainer who has delivered a popular Windows PowerShell workshop to Microsoft Premier Customers worldwide. He has written 9 books including 6 on Windows scripting that were published by Microsoft Press. He has also contributed to nearly a dozen other books. His Windows PowerShell 2.0 Best Practices book for Microsoft Press is currently a best seller. Ed holds more than 20 industry certifications, including Microsoft Certified Systems Engineer (MCSE), the Microsoft Certified Data Base Administrator (MCDBA) and Certified Information Systems Security Professional (CISSP). Prior to coming to work for Microsoft, he was a senior consultant for a Microsoft Gold Certified Partner where he specialized in Active Directory design and Exchange implementation. In his spare time, he enjoys woodworking, underwater photography, and scuba diving.

.

8/04/2012

Which Excel, Visio and other Office products can "Publish" to SharePoint

 

A frequent question I get is "I can't publish to SharePoint". Not all editions of Excel and Visio have the publish feature!

Excel and Excel Services

Any edition of Excel can save files to a SharePoint library. Only the following editions of Excel 2010 can publish to Excel Services:

  • Microsoft Office Professional Plus 2010
  • Microsoft Office Professional Academic 2010
  • Microsoft Excel Stand-Alone 2010

Details: http://support.microsoft.com/kb/2569945

 

Visio and Visio Services

Any edition of Visio can save files to a SharePoint library. The edition needed to use Visio with other SharePoint features varies:

  • SharePoint Workflow import and export through SharePoint Designer 2010: Premium
  • Visual mash-ups with Visio Services: Professional and Premium
  • Publishing of diagrams to SharePoint Process repository: Standard, Professional and Premium
  • Publishing Visio Web (.vdw) drawings to SharePoint: Professional and Premium
  • Automatic Data Linking to data sources in SharePoint: Professional and Premium
  • Real-Time sharing of dynamic, data-driven diagrams via a browser using Visio Services: Professional and Premium

Details: http://visio.microsoft.com/en-us/TryBuy/Pages/Edition_Comparison.aspxhttp://technet.microsoft.com/en-us/library/ee663485.aspx and http://office.microsoft.com/en-us/visio-help/save-diagrams-to-sharepoint-as-web-drawings-HA010357073.aspx

 

SharePoint 2010 Services and Features by edition:

http://sharepoint.microsoft.com/en-us/buy/Pages/Editions-Comparison.aspx

 

.

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.