When we’re designing or mocking up a SharePoint Intranet, Extranet or Internet we always talk about content roll up. SharePoint does a great job with content roll up OOTB (within the same Site Collection at least) using the Content Query Web Part. However, any time you show the client the power of the Content Query Web Part a typical question usually follows…
I love how I can see the top 5 most recent documents… but where is the link to “view more”? How do I get to the rest of the documents?
Like anything else with SharePoint it’s the 80-90% that’s easy and the little questions like this that cause the grief. Now, you could modify the Content Query Web Part styles but that’s not very manageable. Or you could drop a Content Editor Web Part on the page but that seems like a lot of work for one link. Heck, with SharePoint 2010 you could even use an inline Web Part in your main content area and just include the link yourself.
ISN’T THERE AN EASIER WAY?
What if you wanted something that looks like this:
Let’s keep this simple, make it flexible and allow you to use this technique on any Web Part, OOTB or custom.
Let’s keep this simple, make it flexible and allow you to use this technique on any Web Part, OOTB or custom.
THE WEB PART CONFIGURATION
First, we’re going to put the URL that we want the link to point to in the Title URL of the web part. Normally this would make the title of the Web Part clickable… but using some jQuery we can disable that link later.
Next we’re going to use the Description to hold the link caption (You we’re using the description anyways… were you?).
Now when we save the web part SharePoint will automatically display the tooltip of the Web Part title as “Web Part Title – Web Part Description”. We’re going to use this detail to our advantage next.
|
THE JQUERY
The code above is going to perform the following:
- Loop through all Web Part Headers on the page
- Find the title of the Web Part
- Determine if the Web Part is using a description (we make some assumptions to do this)
- Remove the description from the Web Part title
- Make sure the Web Part has a Title URL configured
- Remove the link from the Web Part title
- Add a new table cell at the end of the Web Part title to show our view more link
THE CSS
Last but not least let’s style our links! You can do anything you want at this point but here’s the CSS I’m using in the screenshot above:
jQuery to the rescue… again!
This was the cool Post by Cory Peters
No comments:
Post a Comment