Display Events from a SharePoint Calendar Using jQuery and FullCalendar

This entry is part 1 of 2 in the series Building a Better SharePoint Calendar

As part of a large department site redesign project, I wanted to implement a better calendar solution than what MOSS 2007 gives you OOTB. I remembered coming across the FullCalendar jQuery plugin a while back, so I decided to try using it with the calendar on my department’s site. I haven’t tested this in SharePoint 2010, but it should work just fine regardless of the version (just verify all of the column references in case any of them are named differently).

Prepping the Resources

I downloaded the latest FullCalendar package, unzipped the file, and uploaded the CSS and JavaScript files to a document library on my site. I like to use a library called WebResources and add a choice column with options for “CSS,” “Image,” “JavaScript,” and “jQuery” so I can keep track of all of my various resources in one place, with versioning.

Screenshot of FullCalendar Resources in the WebResources Library
I keep all of my resources in a "WebResources" document library grouped by the type of resource.

Once the files were uploaded, I copied the calendar.aspx page and renamed it CalendarCustom.aspx in SharePoint Designer (SPD). Then I switched back to the web UI, went to the calendar settings, and modified the duplicate “Calendar” view so I could rename it and set it as the default (this is the view that will contain our custom calendar). Next I opened that view and hid the default list view web part for the calendar.

The last step in prepping the page was to open it in SPD and add references to the CSS and JavaScript files that the calendar will need just below the <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> tag on the page (you could also put them in a Content Editor Web Part):

Screenshot of CSS and Script References for FullCalendar
Load the CSS and JavaScript references on the page. This can be done in a Content Editor Web Part, but I prefer to add them in the PlaceHolderMain section.

Setting Up the Data View Web Part

To make this happen, I used a Data View Web Part (DVWP) to output the necessary JavaScript for the plugin to generate the calendar. I selected the web part zone and inserted a new DVWP. I chose the Calendar list as my data source, selected the Title field and inserted it as a “Multiple Item View.”

Screenshot of Calendar Data Source Displayed as a Multiple Item View
Insert a DVWP with the calendar as the data source, and insert the Title field as a "Multiple Item View."

I didn’t want to bog down the browser by loading hundreds of really old events, so I set a filter on the DVWP so that only events with a start time greater than or equal to today minus 90 days would be displayed (see this post for more information on setting up CAML query offsets). This allows people to view events up to three months in the past, as well as current and future events. I also sorted the events by start time in ascending order.

Continue reading

Access Ubuntu VM Files from a Windows Host

This entry is part 4 of 4 in the series WordPress Development Environment

I do most of my WordPress development using a test environment that I installed on a Ubuntu Virtual Machine (VM). This let’s me play around as much as I want without any risk to my production website or my computer; everything is contained within the VM, and it costs me nothing because I only use open-source and/or free software (read about it at http://wp.me/p1iF71-4x).

However, I prefer to do the actual development and testing from Windows 7 because I prefer using it to any other OS. While my VM is running my WordPress installation, I can access the files from my Windows host OS and use development tools like Notepad++ to access the WordPress files via my home network.

To accomplish this, Ubuntu will need to install a sharing service so Windows can “see” it using the virtual network adapter. When we’re finished, the VM will appear to be just another computer on the network.

Enable Sharing

First, navigate to opt/lampp/htdocs and right-click on the wordpress folder. Select “Sharing Options” to open the Folder Sharing window.

Select "Sharing Options" for the wordpress folder.
Select "Sharing Options" for the wordpress folder.

Check the box for “Share this folder” and click the Install Service button when prompted. You’ll need to enter your password. Continue reading

Organize Series Plugin for WordPress

I just installed the Organize Series plugin for this site. Right out of the box it comes with everything needed to organize related blog posts into a “series” of posts with a specific order. I’ve seen this on a lot of other WordPress sites when people do a series of articles about a specific topic. Some of my blog posts are rather long, and I’ve been wanting to post more frequently, so I think this will help because I can link several short posts together into a series rather than spend several days writing a single long post.

I retroactively organized my console emulator posts into a series. They were written specifically as a series, but at the time I didn’t have the means to link them together other than adding a “part 1, part 2, etc.” to the title of each post. Now if you view any one of the posts, you’ll see a message at the top of the post indicating that it is part of a series. The end of the post also includes links to the other posts in the series.

Table of contents for the Installing and Using Console Emulators series
The Organize Series plugin displays a table of contents for the series at the end of each post in the series. With a little CSS I was able to make it fit right in with my theme!

The plugin includes its own CSS for styling the messages and table of contents, but I decided to integrate it more tightly with my “Glass” theme. Fortunately the Organize Series plugin provides a lot of flexibility in modifying the markup of the messages and table of contents. I was able to include my own HTML5 markup and CSS hooks for the plugin. Now it generates an <aside> element for the list of posts in the series and a <nav> element to move forward and backward in the series that I styled to match my overall theme.

Take a look at the link above and let me know what you think; I think it turned out pretty good! When I have more time I’ll probably ditch the auto-generated series information and insert the template tags directly into my theme so I have some more control over how it’s rendered. For now, however, the plugin does a great job with the OOTB options.

Use TinyMCE as the Rich Text Editor in SharePoint Forms

The default rich text editor (RTE) in SharePoint® 2007 doesn’t quite cut it in my opinion, and here’s why:

  • It’s based on an ActiveX control, so it only works in Internet Explorer. This alone is reason enough to replace it.
  • When creating a multiple line of text column in a custom list, you can only choose between “Plain text,” “Rich text,” or “Enhanced rich text” as the format for the column—not a lot of options. What if you want your users to have access to headings or other HTML elements?
  • It generates horrible, deprecated code:
    <DIV>Look at how <EM>bad </EM>this HTML is! If I start <SPAN style="color: #ff6600;">coloring things </SPAN>it gets really messy. I try to make sure I'm not getting too crazy with the content, but many users will select <SPAN style="font-family: 'Comic Sans MS';">their own fonts</SPAN>, <SPAN style="font-size: small;">sizes</SPAN>, <SPAN style="background-color: #33cccc;">colors</SPAN>, etc. instead of keeping things simple, which makes the markup even worse.</DIV>
    <DIV>&nbsp;</DIV>
    <DIV>Why does it use &lt;div&gt; tags instead of &lt;p&gt; tags? Why are the elements in all caps?</DIV>
    <DIV>&nbsp;</DIV>
    <DIV><SPAN style="color: #ff6600; font-family: 'Times New Roman'; font-size: medium;"><STRONG>Now if I try to make an entire section formatting differently, it gets weird with &lt;font&gt; tags and &lt;span&gt; tags.</STRONG></SPAN></DIV>
    <DIV><SPAN style="color: #000000; font-size: xx-small;">&nbsp;</SPAN></DIV>
    <DIV><SPAN style="font-size: xx-small;">Users probably don't know about the Clear Format button, so when they want to add "normal" text after their crazy colored, centered, bolded text, they try to match the normal text with even MORE direct formatting.</SPAN></DIV>
    <DIV><SPAN style="font-size: xx-small;">&nbsp;</SPAN></DIV>
    <DIV><SPAN style="font-size: xx-small;">Now try using this content in a branded site and see if your CSS holds up. Let a user edit this a few times and you'll have nested &lt;span&gt;s all over the place with all kinds of formatting.</SPAN></DIV>
    
  • Even the Full HTML RTE that you get on Publishing Pages (or if you create your own site column of this type) generates the same kind of markup. You have a few more options, like selecting basic HTML elements (paragraphs, headings, address, etc.), but you still can’t customize what appears.

A decade ago this RTE would have been really cool, but in today’s standards-compliant, feature-rich web, it just doesn’t hold up.

Enter TinyMCE, an open-source RTE with tons of customization OOTB, and even more thanks to numerous plugins (you can even write your own plugins if you need something that it doesn’t have). In this post I’ll show you how I replaced the SharePoint RTE with TinyMCE on my custom list forms using a little jQuery.

Note: This isn’t a tutorial about using TinyMCE for all rich text editing in SharePoint; it shows you how to use it on a per-form basis. Continue reading

Thoughts on SPTechCon Boston 2011

I just got back home from SPTechCon in Boston, and I wanted to write down some of my thoughts on it while they are still fresh. This was my first in-person attendance at a SharePoint conference, and I have to say I had a great time!

Location

Having the conference in Boston was cool, because I got to leave Phoenix for a few days and experience a new city. The sights, the sounds, the food, the accents are all a fun cultural experience. To me this is not a trivial aspect of a conference. If I’m going to SPTechCon or any other conference, I want to make sure I take time to see more than just the inside of the hotel while I’m there.

View from the Sheraton Boston
The view from my hotel room. Boston is a beautiful city.
Dinner at McCormick & Schmick's Seafood Restaurant‎
The local seafood cuisine was excellent!

Staying at the Sheraton in downtown Boston was a treat as well. The hotel itself had nice rooms, a courteous staff, and good facilities for hosting the sessions, lunches, keynotes, and exhibits. It was located near a lot of great restaurants, bars, and shopping. I could walk to the train in less than 5 minutes, and the cab ride from the airport was less than 20 minutes.

Continue reading

SharePoint Contextual Search – Updated

In a recent project created a page that features several Data View Web Parts pulling information from multiple lists within the site to create a dashboard-like experience. The stakeholders also wanted to be able to quickly search within each list, so I decided to include a custom search box at the top of each data view web part.

At first I thought I could use my custom search box that I wrote about in a previous post. The problem with that solution is that the JavaScript I created only works for a single search box because the ID is hard-coded into the functions. Therefore I modified the function to accept an ID attribute so it would accommodate multiple search boxes on the same page.

Updated Script and HTML

Here is the updated script:

// Search for the terms when the Search button is clicked

function customSearch(inputId,type,site,scope) {

	var searchUrl = site + "/_layouts/OSSSearchResults.aspx?" // Or "/_layouts/SearchResults.aspx?" if WSS 2003 or SP2010 Foundation
	var searchTerm = "&k=" + document.getElementById(inputId).value;
	var listParams = "&cs=This%20" + type + "&u=" + scope;
	window.location.href = searchUrl + searchTerm + listParams;
}

// Initiate the customSearch function when the Enter key is pressed

function searchKeyPress(buttonId,e) {
	// look for window.event in case event isn't passed in
	if (window.event) {
		e = window.event;
	}
	if (e.keyCode == 13) {
		document.getElementById(buttonId).click();
	}
}

Continue reading

Create a Shortcut to Start XAMPP in Ubuntu

This entry is part 3 of 4 in the series WordPress Development Environment

I do most of my WordPress development using a combination of VirtualBox and Ubuntu. Over time I’ve developed a few simple tips that make my workflow a little more efficient, so I wanted to share them with anyone else who read my previous tutorial on setting up a VM as a WordPress development environment.

Running VirtualBox takes up a significant amount of RAM, so I like to shut it down when I’m not using it. XAMPP needs to be manually restarted the next time I use the VM, which can be a little tedious after a while.

To get around this, I created a simple launcher (i.e. a shortcut for us Windows folks) on the Ubuntu desktop for the Terminal command to start XAMPP. This way I can start it with just a double-click of the mouse instead of launching the terminal and typing in the command. If you want to create a similar launcher, follow these steps:

  1. Right-click on the Ubuntu desktop and select “Create Launcher.”
  2. Select “Application in Terminal” for the Type.
  3. Enter “Start XAMPP” for the Name (or enter whatever you want to call your shortcut).
  4. Enter “sudo /opt/lampp/lampp start” into the Command field.
  5. Click OK.
Create Launcher
Enter the XAMPP startup command to create a launcher for it.

Now your laucher for XAMPP will be on the desktop and save you a few clicks and keypresses when you need to start it up. If you have any other suggestions leave them in the comments!

Android + Dropbox + KeePass + LogMeIn + Carbonite = Mobile Sync Awesomeness

I’ve been wanting to write this blog post for a while, but I kept putting it off to focus on SharePoint stuff and my updated WordPress theme (I’ll be posting about my updated theme soon). I was a little late to the smartphone party, but last year I finally picked up my first smartphone—a Droid Incredible. Because I’ve had such a great experience using it with these programs, I wanted to share it with others. This is geared toward Android™ users, but most of this stuff will work on iPhone® too (Windows® Phone 7 and Blackberry® users are on your own—and if you own a Blackberry, I’m sorry…).

Android + Dropbox + KeePass + LogMeIn + Carbonite
Android + Dropbox + KeePass + LogMeIn + Carbonite = Mobile Sync Awesomeness!

Most of these programs and apps are free, but there are a couple that you’ll need to pay for. If you want a totally free solution, you can still get a lot of value out of this solution even without the paid apps/software. Continue reading

Using a Current Date Offset in a CAML Query to Filter List Items and Other Useful CAML Resources

Recently I needed to create a Data View Web Part in MOSS 2007 that displayed all upcoming events, as well as all events that took place within the last week. The out of the box filtering options in SharePoint Designer (SPD) let you filter a Date and Time column by the “[Current Date]” or by a specific date. Unfortunately the UI does not let you specify an offset for the “[Current Date]” filter, but I found a few resources that showed me how to modify the CAML query that creates the filter to accomplish a date offset.

Setting Up the Filter

I set up my filter (Common Data View Tasks > Filter) to show all items whose Start Time (aka @EventDate) is greater than or equal to “[Current Date]” to build the initial CAML query.

[Current Date] filter
Set the DVWP to filter items based on the current date.
Next I switched to split view and found the CAML query in the code. It’s located in the <SharePoint:SPDataSource> tag (in the <DataSources> section):

<DataSources>
	<SharePoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Geq&gt;&lt;FieldRef Name=&quot;EventDate&quot;/&gt;&lt;Value Type=&quot;DateTime&quot;&gt;&lt;Today/&gt;&lt;/Value&gt;&lt;/Geq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;" UseInternalName="true" ID="dataformwebpart2">
	<SelectParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="537F0267-8B1E-47CD-8FC7-356D4949F604"/></SelectParameters>
	<UpdateParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="537F0267-8B1E-47CD-8FC7-356D4949F604"/></UpdateParameters>
	<InsertParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="537F0267-8B1E-47CD-8FC7-356D4949F604"/></InsertParameters>
	<DeleteParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="537F0267-8B1E-47CD-8FC7-356D4949F604"/></DeleteParameters>
	</SharePoint:SPDataSource>
</DataSources>

Continue reading

Create an Organization Chart in MOSS 2007 Using a Contacts List

Note: This article was originally posted on NothingButSharePoint.com, but some of the code snippets were unescaped when it was published, so I decided to post it on my own blog with the correct code snippets.

I was recently tasked with finding a way to maintain an org chart for my department. If this were a single-use resource that didn’t need to be updated frequently, I would have chosen to create it in a program such as Visio or Adobe Illustrator (even PowerPoint would work well with its SmartArt capabilities). However, this is something we want to be as maintenance-free as possible so we aren’t rebuilding it as people come and go.

The department’s operations team already maintains a list of everyone in the department by using a SharePoint Contacts list, so we can pull data from that and build the org chart dynamically. This method does not require any custom code or web parts, so there’s no need to deploy anything on the server!

Sample Org Chart
This is the org chart that will be generated.

Continue reading