Chapter 10. SharePoint 2010 Tab Page

When the amount of content to be shown on a page exceeds the viewable real estate, users have to scroll down the page to view the content they wish to see. Scrolling is something to be avoided for an optimum user experience. Less scrolling means a much better experience for the user. SharePoint, however, does not provide a way to make this happen.

One of the better solutions to this problem in SharePoint is the use of tabs. Tabs allow the content manager to place more information on a single page while not forcing the user to scroll up and down the page to get to that information.

Wouldn’t it be great to have a solution that allowed you to have a page that had tabs incorporated and ready for you to use?

The goal, then, is to create a Tab page that will do the following:

What, then, will the end product look like? Well, it will look something like the pages shown in Figure 10-1 and Figure 10-2.

SharePoint 2010 Tab page example showing web part placement

Figure 10-2. SharePoint 2010 Tab page example showing web part placement

You will find that each tab has a header, left, middle, right, and footer section to add web parts. This provides a lot of customization for each tab, as the layout of your web parts provides flexibility in configuration and placement.

Now let’s implement the solution. Here is a brief overview of the three basic steps we will carry out to create a tab page:

Once these steps are completed, you will be able to add content to your new tab page. Now onto the details!

Now you can edit the HTML Forms web part. Open the Source Editor and enter the following code:

<!-- Code to add Tabs -->
<div id="tabs">
<ul class="tabNavigation ms-WPBody">
<li><a href="#tab-1" class="selected ms-topnavselected"><span>TAB 1</span></a></li>
<li><a href="#tab-2" ><span>TAB 2</span></a></li>
<li><a href="#tab-3" ><span>TAB 3</span></a></li>
<li><a href="#tab-4" ><span>TAB 4</span></a></li>
<li><a href="#tab-5" ><span>TAB 5</span></a></li>
<li><a href="#tab-6" ><span>TAB 6</span></a></li>
<li><a href="#tab-7" ><span>TAB 7</span></a></li>
<li><a href="#tab-8" ><span>TAB 8</span></a></li>
</ul>
<div style="clear: both"></div>
</div>

You will need to decide the number of tabs you want. To have fewer than eight tabs, I recommend that you add <!--& --> to the beginning and end of the lines of code that you use to denote the tabs (those that start with <li> and end with </li>). This will allow you easily to add a tab back if you need it in the future, without having to remember the code you are adding.

<!--<li><a href="#tab-8" ><span>TAB 8</span></a></li>-->

You can give the tabs different names by inserting the name for the tab between the code <span> and </span> for each tab:

<li><a href="#tab-2" ><span>TAB NAME</span></a></li>

Finally, decide if you want the Tab page Help link to be shown. If you decide that the Help link should be hidden, add the following code:

<!-- Code to hide Tab Page Help Link -->
<script type="text/javascript">
   $(document).ready(function() {
        $('#TabPageHelp').hide();
   });
</script>