Generic Errors with Lists and Manage Content and Structure Tool

image

An unexpected error has occurred. Yep. Very helpful! Recently, when attempting to use the Manage Content and Structure tool (found under Site Actions > Manage Content and Structure), I received the above error. Looking into the ULS logs, all I was able to get ahold of was a System.NullReferenceException. Again, not really handy, or useful, at all.

I was able to determine that it had to probably be due to a list… turns out, we had deactivated and retracted several features from our farm recently, several of which relied on custom lists to store the data. If I go to View All Site Content (Site Actions > View All Site Content), and click on one of these lists, I get a similar error to the above.

Luckily, one of the times when attempting to launch the Manage Content and Structure Tool, I was able to get this error in the ULS logs.

Failed to determine the setup path of the list schema for feature {553B9E4F-C7EA-4442-845F-94390C1EAE44}, list template 10000.

So, basically, we need to remove these lists. We cannot get into the “Delete this List” option within the List management screen – otherwise you’ll get an error similar to the above. I also attempted to use SharePoint Manager 2010, which also gave an error. I just couldn’t delete the list using traditional means…

You have two options here…

  1. Write some code to delete the list (C#, PowerShell… whatever you desire)
  2. Use Gary LaPointe’s STSADM extensions and PowerShell scripts.
    1. Remove-SPList PowerShell Command
    2. gl-deletelist STSADM command

Either of those should do the trick! Now, to get the List URL is simple, the lists should still appear under View All Site Content, just right-click and copy the shortcut to the list view, for example: http://sharepointsite.com/Lists/SomeCustomList/AllItems.aspx

Use that when calling those commands with the URL parameter, and you’re good to go.

Speaking at Week3–Collaboration Technology Interest Group on September 21st, 2011

image

One of the groups I help out with has been Week3. And while I have helped in the planning and marketing of it for some time, I have yet to speak for one of its online sessions. This is changing next month, I will be presenting a session on search. See below for more information on Week3, as well as the session, and I hope you can make it! (it’s free, and online!)

 

Who? What? Where? – Searching in SharePoint

This session will cover the importance of search in a SharePoint environment, as well has how to make use of it from the end user, site collection administrator level. We will not discuss search architecture, or managing search in Central Administration. This session will focus on finding information, as well as making information findable.

When: September 21st, 2011 – 11AM EST

Register: https://www1.gotomeeting.com/register/898927585

 

What is Week3?

We are an online interest group designed to provide a platform of discussion and learning around how collaboration technologies can optimize business productivity. Our focus is on ROI, not code.

Week3’s mission is to create an open, unbiased community of business professionals, dedicated to the growth and development of collaboration techniques, using technologies such as Microsoft SharePoint (2010, MOSS, WSS) as a means to improving organizational productivity.

For more information on Week3, visit http://www.week3.org

Recap and Resources from SharePoint Saturday–The Conference

image

Organizing and maintaining a SharePoint Saturday can be hard work. LOTS of hard work. Luckily, the way we run SharePoint Saturday Boston, we have less hard work than other SPS events. We put the responsibility of ordering shirts, pads, pens, food, etc. on the sponsor, so we do not only have to deal with the event, speakers, sponsors, etc., so we do not also have to order shirts, food, etc. It makes life a lot easier.

Then there are other SharePoint Saturday events, such as SharePoint Saturday New York, they take it to the next level, and deal with all of that. Now, these are just single day events.

Now, with SharePoint Saturday – The Conference, this was a 3-day event, they had roughly 1800 people registered, well over a thousand attend. IMAGINE STUFFING 1800 ATTENDEE AND SPEAKER BAGS?! GAH! They had LOTS of volunteers however. It was not the best well-oiled machine, but, there was no chance of the motor seizing up on this one. They did one heck of a job. This is not to slight the conference in any way, the organizers of this event actually have day jobs, that are not all about planning and putting together conferences, so this was done in their spare time, if they had any.

I was amazed at the level of sophistication that a basically free ($39-$59 for a 3 day event is the best price out there for a SharePoint conference of this size). They had the ability to change name tags on the fly, lots of volunteers had radios, there were session and schedule updates on monitors around the campus, people all over the place directing traffic and offering help getting from building to building, and if for some reason your session time and date had changed, people to find you and drag you to them! (more on that in a moment).

Great job by everyone involved! I was happy to be a speaker and attendee at the conference, and look forward to another one down the road!

With that, I delivered 3 sessions. Below is information on each, as well as slide decks. Thank you to all who attended my sessions!

9 Ways to Become a (SharePoint) Rock Star

This was supposed to take place on Saturday, not Friday. So, when I arrived at the conference on Friday at 5 after 11 in the morning, I saw the lunch table, and headed over… got a plate of food, and then all of a sudden, I was approached by one of the volunteers, and a friend of mine, Jennifer, and the interaction went something like this…

Jennifer: “C’mon! You’re 15 minutes late for your session!”

Me: “What? I don’t have a session until the end of the day”

Jennifer: “No, you have one now”

Me: “Ok then, what session is it?”

Jennifer: “9 Ways to Become a (SharePoint) Rock Star”

[EDITORS NOTE: She did not exactly use parenthesis when she said it.]

Me: “That’s not until tomorrow”

Jennifer: “There are 40 people waiting in there for you now”

Me: “Uh oh, [expletive deleted] [expletive deleted] [expletive deleted] [expletive deleted] [expletive deleted] [expletive deleted] [expletive deleted], Let me grab my bag!”

Jennifer: ”Let’s go!”

[winded dash to another building … then walking, well, being dragged into the classroom]

Me: “Sorry I am late everyone! I slept late and am hung over, you know, living the rock star lifestyle”

…and then we began the session, after my laptop booted up. So we only got through about 6 of the 9 steps. Luckily, Christian Buckley (the band broke up before the session, so he wasn’t there), is starting a blog series at EndUserSharePoint.com here 9 Ways to Become a SharePoint Rock Star, which will cover each of our “9 Ways”.

For some background on “the best fake SharePoint band EVER, EVER”…

Our lightning talk from SPTechCon in Boston in June, 2011

 

Horse’s End–Behind the Music

 

Legal Notice from Christian for SPSTCDC

and without further ado… the slide deck.

Just Freakin’ Work! Overcoming Hurdles in SharePoint Development

This basically boils down to a best practices around SharePoint development. As well as a fun edu-tainment session with my co-presenter, Mark Rackley. We had a blast, had some good questions, and got through the entire session. Here’s the deck!

Planning and Configuring Extranets in SharePoint 2010

And my last session, which after this was delivered, I had to run to the airport to head home. Again, a great session, great questions, and again, finished up on time. I hope to have that Cloudshare virtual image up and running soon.

Recap and Resources from SharePoint Saturday NYC

I have to hand it to the organizers of the event, Becky Isserman (@MossLover), Jason Gallicchio (@PrincetonSUG), Greg Hurlman (@ghurlman), and Tasha Scott (@TashasEv) as well as their volunteers, for putting together once of the best organized SharePoint Saturdays I have been to. Great job! Lots of great sessions, sponsors, and speakers made this quite the memorable event! I was able to connect with old friends, and meet plenty of new ones.

The organizers also did something very special and unique with the speaker, volunteer, and organizer shirts – each of them either had a patch for the NYPD, NY Port Authority, or FDNY, remembering the attacks on the World Trade Center, as in just over a month from now, will be the 10th anniversary of that tragic day, in which thousands of lives were lost. This shirt will be definitely one of the conference shirts that I will be holding on to. There were lots of conversations about that day – the people we knew, where we were, and what we were doing… and how it has affected our lives since.

I had a great time giving my session (once I caught my breath after literally running around right up until the starting bell, searching for a power adapter, as mine would not work!), and had a lot of great questions from the crowd! With that, here are my slides from the event, with one important update – the CloudShare link no longer works… found the expiration notice in my junk mail folder the day after the environment was removed 😦 I will work on getting a new one up and running within the next couple of weeks – then the link should be functional again.

 

 

Thank you all for attending, if you were able to make it. Someone was even there due to my extranets blog post series (Part 1, Part 2, Part 3), so I know at least once person is reading this!

If you’re in the DC area this week, be sure to catch my session at SharePoint Saturday – The Conference!

Schedule Posted for SharePoint Saturday–The Conference

image

If you’ve read my last post on the matter, or, if you are reading this for the first time, or, just do not remember anything I write… the schedule (or “shedjule” if you’re British, or, just are into non-American English dialect), has been posted for SharePoint Saturday – The Conference in (well, near) Washington, D.C.

Find it here: http://www.spstc.org/blog/Lists/Posts/Post.aspx?ID=32

I’ve also copied and pasted it below, saving you a step!

image

“Sign me in automatically” in Forms Authentication

image

Now this is not just limited to SharePoint, but, since my main focus is SharePoint, this is where I come across this issue the most. When you log in with SharePoint via Forms Based Authentication, there is that little “Sign me in automatically” checkbox below the FBA login form. If you check this, you may realize that a few hours later, when you go to log back into the site, it does not seem to actually remember you at all. That is because by default, it will only remember you for 30 minutes. We can change this quite easily however… This option is controlled within your web application configuration file (web.config) on the server.

If you open this file directly, search for <authentication mode=”Forms”> under <system.web>, you will see, by default, this:

<authentication mode="Forms">
<forms loginUrl="/_login/default.aspx" />
</authentication>

You can also look in IIS as well, under the Configuration Editor feature in the Management section of the web application

image

 

If we expand system.web, and click on authentication

image

Now, the two options we want to look at in here are timeout, and sliding expiration…

image

The definitions for both of these settings are below, taken from MSDN.

When the SlidingExpiration is set to true, the time interval during which the authentication cookie is valid is reset to the expiration Timeout property value. This happens if the user browses after half of the timeout has expired. For example, if you set an expiration of 20 minutes by using sliding expiration, a user can visit the site at 2:00 PM and receive a cookie that is set to expire at 2:20 PM. The expiration is only updated if the user visits the site after 2:10 PM. If the user visits the site at 2:09 PM, the cookie is not updated because half of the expiration time has not passed. If the user then waits 12 minutes, visiting the site at 2:21 PM, the cookie will be expired. (from: http://msdn.microsoft.com/en-us/library/system.web.configuration.formsauthenticationconfiguration.slidingexpiration.aspx)

The amount of time in minutes after which the authentication expires. The default value is 30 minutes. (from: http://msdn.microsoft.com/en-us/library/system.web.configuration.formsauthenticationconfiguration.timeout.aspx)

I suggest setting this to something much higher… if your users will generally log in once a month, setting this to a couple of months, will ensure they are remembered, and with sliding expiration configured, if they log in during the 3rd month, then the system will reset the time on that cookie, remembering them for another 3 months from that date. For sites which have users logging in less often, setting this to a year will be a decent bet that this will remember them for some time. A year in minutes would be: 525600

Hopefully this helps in your configuration of FBA for SharePoint, as well as other FBA applications.

Registration open for Boston Area SharePoint Users Group on 8/10/11

BASPUG_195square_initialsRegistration is now open for the August 10th, 2011 meeting of the Boston Area SharePoint Users Group, at the Microsoft New England Research and Development Center (NERD) in Cambridge, MA.

August 10th, 2011 Meeting Information

PRESENTER

The presenter for our next meeting Paul Schaeflein of Schaeflein Consulting. He will be presenting "I need to make SharePoint look like that!"

AUDIENCE: Developer (Level 200)

SESSION ABSTRACT
How do we deploy custom branding to SharePoint? We will start with the assets provided by our designer and fit them into a predictable, repeatable process. We will also discuss techniques to enforce the brand, enhance the navigation and put some professional touches to the solution

ABOUT PAUL
Paul Schaeflein (MVP, MCPD) is a solution architect/developer with experience in all versions of the SharePoint platform. Paul is a top-rated speaker, having presented at the Microsoft SharePoint Conference and TechEd conferences, as well as user groups. Paul has more than two decades experience in architecting, designing and developing software solutions. This experience covers a vast range of technologies, languages and industries. Having developed many line-of-business applications, Paul has a firm grasp on the challenges that corporate developers face when integrating them into a corporate portal.

MEETING SPONSOR – Rackspace

Fanatical Support® has made Rackspace the world’s leader in hosting. We deliver enterprise-level hosting services to businesses of all sizes and kinds around the world. We got started in 1998 and since have grown to serve more than 99,000 customers, including over 80,000 cloud computing customers. Rackspace integrates the industry’s best technologies for each customer’s specific need and delivers it as a service via the company’s commitment to Fanatical Support. Our core products include Rackspace Managed Hosting, The Rackspace Cloud™ and Rackspace Email & Apps. There are currently over 2,900 Rackers around the world serving our customers. More information at http://www.rackspace.com.

SUSTENANCE
Food and beverages will be provided at the event!

RAFFLE PRIZES
We will be handing out raffle tickets at the BASPUG meetings.

LOCATION
We will be meeting at the Microsoft New England Research and Development Center (NERD) at One Memorial Drive, Cambridge, MA.

LINKED IN
Join our group on LinkedIn today to connect with the rest of the BASPUG members, and spread the word!

FACEBOOK

We are also on facebook! http://www.facebook.com/#!/pages/Boston-Area-SharePoint-User-Group/113652405354617

TWITTER
Follow news about the Boston Area SharePoint Users Group on twitter by following us @BASPUG, and by using the hashtag #BASPUG

Speaking at SharePoint Saturday–The Conference

image

The first event of it’s kind, SharePoint Saturday – The Conference (it’s not just for Saturdays anymore! However, this will end on one…), and I am pleased to be a part of it. I’m also very excited to see that SharePoint Saturday has grown so much over the past couple of years, and now there is a full 3-day conference. SharePoint Saturdays are great ways to share your knowledge with others, learn from peers, experts, MVPs and Microsoft Certified Masters. SharePoint Saturday holds a special place for me, as that is where I got my start speaking on SharePoint, back in the beginning of 2009 at SharePoint Saturday Boston. Since then I have spoken at 11 others to date from New York to New Orleans, and have helped organize SharePoint Saturday Boston since the beginning of 2010.

Unlike usual SharePoint Saturdays however, this one is not free, but pretty close to it as far as conference fees go. The current rate is $39, which will go up to $59 soon, so if you want to save twenty bucks… register today!

I could write-up all of the information about the conference, but it has already been done on the site, so why reinvent the wheel (http://www.spstc.org/Pages/About.aspx) – the text below is a copy of that.

WHAT

A community-focused, educational event filled with sessions from respected SharePoint professionals and executives covering a wide range of technical and business topics.

WHO

Anyone who interacts with SharePoint and its related technologies: Tracks for IT Pro, Developers, End Users, Business Process Owners, the Cloud and more!

WHERE

Northern Virginia Community College

Annandale Campus, Annandale, VA

(Visit the website here.)

WHEN

Thursday, August 11 – Saturday, August 13, 2011: 8 am – 6 pm

Friday Night Attendee Event: 6 pm – 11 pm

WHY

SharePoint Saturdays are a community sponsored event with a huge following. As we take the SharePoint Saturday event to the next level, the goal remains the same: to encourage community participation and lower the barriers to learning SharePoint.

For attendees in any role (End User, IT Professional, Business Manager or Developer), this conference provides an unparalleled level of training, sharing, networking and one-to-one interaction with the SharePoint community. It’s not to be missed!

HOW

Registration Fee:

$39 Early Bird (until August 7, 2011)

$59 for Regular & Walk-Ins

(discounts available for groups of 10 or more)

And there are some FAQ’s on the conference about page as well… http://www.spstc.org/Pages/About.aspx

I will be presenting 3 sessions there, so please drop in to one and say hello if you go!

 

9 Ways to Become a (SharePoint) Rock Star

Co-Presented with Christian Buckley

Session Level: 100

Session Type: End User

So you want to become a rock star? We’re talking actual rock star – not a metaphor for “finding stardom” at your company, but that little “band thing” you do on the side after putting in your 9-to-5 each day.
In this session, we will lead you on a fun and adventurous journey where you can not only learn SharePoint, but springboard into that life of fame and rock stardom that you’ve been dreaming of, using the tools at your disposal during the daily grind. If, by chance, your wildest dreams of becoming a rock star do not come to fruition, you can be rest assured that you can apply what you learn in this session to become a SharePoint rock star. Because its always good to have a backup plan.

 

Just Freakin’ Work! Overcoming Hurdles and Avoiding Pain in SharePoint Custom Development

Co-Presented with Mark Rackley

Session Level: 200

Session Type: IT Pro / Developer

“Why am I getting a security error??” “Why does my code work sometimes, but not others?” “I wonder if McDonalds is hiring.” Writing custom code in SharePoint opens up unlimited possibilities but also throws many hurdles in your way that will slow you down if you don’t take them into account. So, before giving up and searching for careers in the fast food industry, equip yourself with the knowledge you need to succeed in writing custom code for SharePoint.
Attendees will learn:
1. Commonly used methods to improve functionality and performance
2. Best practices for disposing of SP Objects
3. How to avoid common issues when writing custom code for SharePoint
PREREQUISITES: Developers need to have a basic knowledge of SharePoint, know C# and be comfortable in Visual Studio.

 

Planning and Configuring Extranets in SharePoint 2010

Session Level: 300

Session Type: IT Pro / Admin

Most companies, large or small, require contact and collaboration with external entities, whether they are vendors, clients, or contractors. SharePoint gives us the ability to open up portals for collaboration with these external entities – this session will show you how to accomplish this using SharePoint 2010.
We will review what is required to make SharePoint “open” to the external world, discuss scenarios regarding security and privacy, as well as walk through configuring Forms Based Authentication, Claims Based Authentication, as well as using Business Connectivity Services in SharePoint 2010, to authenticate, and manage our external users.
Once completing this session, you should have a firm grasp on how to configure an extranet environment using SharePoint 2010, as well as what should be considered during the planning of your extranet scenarios.

Imtech Content Query Web Part for SharePoint 2010

If you are running a publishing site in SharePoint, then you know the name Waldek Mastykarz. If you don’t, you should. His blog is filled with many posts on SEO, Content Query Web Parts, and much more. I had a client request to add some paging into the Content Query Web Part, and stumbled upon Waldek’s Imtech Content Query Web Part for SharePoint 2010. This was the perfect solution for my client, but I needed to make a few modifications… this post will go over the modifications and issues we encountered and resolved.

The Issues and Modifications

  • My client had many customized item styles they still wanted to use, so using the example ImtechContentQueryMain.xsl and ImtechItemStyle.xsl sheets was out of the question, so I had to retro-fit their existing XSL files with the paging controls.
  • The paging control appeared at the top of the CQWP, we needed it at the bottom.
  • We encountered an error relating to trusted XSL files in a sub-site, we did not want to have duplicate XSL files all over the place.
  • Limiting the number of records returned on large lists, so the paging controls did not stretch out the page size.

Retro-fitting existing XSL Stylesheets with the Paging Controls

As mentioned, we wanted to use our existing stylesheets, other than the ones available from the Codeplex project page: http://imtech.codeplex.com/releases/view/39782#DownloadId=104110

To do this, I loaded up a default ItemStyle.xsl file (without any changes), as well as the ImtechItemStyle.xsl file in Beyond Compare, and copied the differences out into our custom ItemStyle.xsl.

The first step, is to copy the PagingControls template into your ItemStyle.xsl – it can be placed anywhere.

  <xsl:template name="PagingControls">
    <xsl:param name="Page" />
    <xsl:param name="NumPages" />
    <xsl:if test="$Page = 1">
      <xsl:text disable-output-escaping="yes"><![CDATA[<div>]]></xsl:text>
      <xsl:if test="$PageNumber &gt; 1">
        <xsl:variable name="PreviousPageNo" select="$PageNumber - 1"/>
        <a href="?{$PagingParameterName}={$PreviousPageNo}">
          <xsl:text disable-output-escaping="yes"><![CDATA[&laquo;]]></xsl:text> Prev
        </a>
        <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
      </xsl:if>
    </xsl:if>
    <xsl:choose>
      <xsl:when test="$Page = $PageNumber">
        <strong>
          <xsl:value-of select="$Page"/>
        </strong>
      </xsl:when>
      <xsl:otherwise>
        <a href="?{$PagingParameterName}={$Page}">
          <xsl:value-of select="$Page"/>
        </a>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
    <xsl:if test="$Page &lt; $NumPages">
      <xsl:call-template name="PagingControls">
        <xsl:with-param name="Page" select="$Page + 1"/>
        <xsl:with-param name="NumPages" select="$NumPages" />
      </xsl:call-template>
    </xsl:if>
    <xsl:if test="$Page = $NumPages">
      <xsl:if test="$PageNumber &lt; $NumPages">
        <xsl:variable name="NextPageNo" select="$PageNumber + 1"/>
        <a href="?{$PagingParameterName}={$NextPageNo}">
          Next
          <xsl:text disable-output-escaping="yes"><![CDATA[&raquo;]]></xsl:text>
        </a>
      </xsl:if>
      <xsl:text disable-output-escaping="yes"><![CDATA[</div>]]></xsl:text>
    </xsl:if>
  </xsl:template>

Then, once that was in there, we need to modify the item template(s) we are using to support paging. To do this, we will use the Default template for ease of use…

Locate the start of the template

<xsl:template name="Default" match="*" mode="itemstyle">

Next, add in the following parameter right after that line in your XSL item template

<xsl:param name="CurPos" />

Your item template should now look like this:

  <xsl:template name="Default" match="*" mode="itemstyle">
    <xsl:param name="CurPos" />
    <xsl:variable name="SafeLinkUrl">
     ...

This adds in a parameter which gets the current position (row) from the list(s), we need this.

Next, we want to add in the paging. We’ll add it in its default location here, at the top of the CQWP, and show you how to move it to the bottom later in this article. Within your Default template, locate the following two lines

    </xsl:variable>
    <div class="item">

Now, we will paste in the following BEFORE <div class=”item”> and after </xsl:variable>

    <xsl:if test="$CurPos = 1 and $PageSize &gt; 0">
      <xsl:variable name="NumPages" select="ceiling($TotalRecords div $PageSize)"/>
      <xsl:if test="$NumPages &gt; 1">
        <xsl:call-template name="PagingControls">
          <xsl:with-param name="Page" select="1" />
          <xsl:with-param name="NumPages" select="$NumPages" />
        </xsl:call-template>
      </xsl:if>
    </xsl:if>

This will call the PagingControls template we added earlier, if the $CurPos = 1 (this is the first row in our CQWP), and the $PageSize is greater than 0 (meaning that we are using the paging feature in this web part).

Save your ItemStyle.xsl, and we need to next compare ImtechContentQueryMain.xsl, and ContentQueryMain.xsl.

In the ContentQueryMain.xsl file, locate this line towards the top of the file:

<xsl:param name="ClientId" />

Found it? Awesome. Paste in the following lines below that line:

    <xsl:param name="PageSize" />
    <xsl:param name="PagingParameterName" />
    <xsl:param name="TotalRecords" />
    <xsl:param name="PageNumber" />
    <xsl:param name="WebPartTitle" />
    <xsl:param name="WebPartDescription" />
    <xsl:param name="WebPartTitleUrl" />
    <xsl:param name="Locale" />
    <xsl:param name="GroupStyle" />
    <xsl:param name="ItemStyle" />

The next thing we have to do is include the CurPos (current row position) in the template OuterTemplate.CallItemTemplate. Search for that in the file, and then find <xsl:otherwise> within that template. After

<xsl:apply-templates select="." mode="itemstyle">

Add in

<xsl:with-param name="CurPos" select="$CurPosition" />

So the full template should look like this

  <xsl:template name="OuterTemplate.CallItemTemplate">
    <xsl:param name="CurPosition" />
    <xsl:value-of disable-output-escaping="yes" select="$BeginListItem" />
    <xsl:choose>
      <xsl:when test="@Style='NewsRollUpItem'">
        <xsl:apply-templates select="." mode="itemstyle">
          <xsl:with-param name="EditMode" select="$cbq_iseditmode" />
        </xsl:apply-templates>
      </xsl:when>
      <xsl:when test="@Style='NewsBigItem'">
        <xsl:apply-templates select="." mode="itemstyle">
          <xsl:with-param name="CurPos" select="$CurPosition" />
        </xsl:apply-templates>
      </xsl:when>
      <xsl:when test="@Style='NewsCategoryItem'">
        <xsl:apply-templates select="." mode="itemstyle">
          <xsl:with-param name="CurPos" select="$CurPosition" />
        </xsl:apply-templates>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="." mode="itemstyle">             

<xsl:with-param name="CurPos" select="$CurPosition" />  </xsl:apply-templates> </xsl:otherwise> </xsl:choose> <xsl:value-of disable-output-escaping="yes" select="$EndListItem" /> </xsl:template>

With the bolded line above being what we’ve added to it from the Imtech file. You can now save and close the ContentQueryMain.xsl file. And that is it for the modifications required on both the ItemStyle.xsl and ContentQueryMain.xsl files! You should now be able to use paging using your item styles and the Imtech Content Query Web Part.

Moving the Paging Control to the Bottom

Now, with the above in place, or using the Imtech XSL stylesheets, you will notice that the paging control is at the top. Well… if we want to keep in line functionality similar to SharePoint, we want to move the paging control to the bottom of the page. To do so, open up your ItemStyle.xsl file. Locate your default item style template (same one used in the last section), and locate this code, which appears after </xsl:variable> and before the starting DIV tag

    <xsl:if test="$CurPos = 1 and $PageSize &gt; 0">
      <xsl:variable name="NumPages" select="ceiling($TotalRecords div $PageSize)"/>
      <xsl:if test="$NumPages &gt; 1">
        <xsl:call-template name="PagingControls">
          <xsl:with-param name="Page" select="1" />
          <xsl:with-param name="NumPages" select="$NumPages" />
        </xsl:call-template>
      </xsl:if>
    </xsl:if>

Just cut that out. We will be moving it to the bottom of the template. now, locate the following, which ends the item style

        </div>
    </xsl:template>

Just before the closing DIV, paste the above code back in. If you save the file (and check it in – needs to be checked in to be viewable), you will see that it appears AFTER the first row returned by the CQWP. We need to add a little logic into here so we can determine if we are on the last row, and in the case of the last page where we might not have a full page, determine what the last item number is for that last page, and then display the paging controls. So the code below would be used instead of the default we just added in here.

Now, I am also going to center mine as well, so it looks a little better than just being left justified.

            <center>
              <xsl:if test="$PageSize &gt; 0">
                  <xsl:variable name="NumPages" select="ceiling($TotalRecords div $PageSize)"/>
                  <xsl:variable name="PageBeforeLast" select="$NumPages - 1"></xsl:variable>
                  <xsl:variable name="CountBeforeLastPage" select="$PageBeforeLast * $PageSize"></xsl:variable>
                  <xsl:variable name="LastPageCount" select="$TotalRecords - $CountBeforeLastPage"></xsl:variable>
                      <xsl:if test="$PageNumber = $NumPages and $CurPos = $LastPageCount">
                            <br/>
                            <xsl:call-template name="PagingControls">
                              <xsl:with-param name="Page" select="1" />
                              <xsl:with-param name="NumPages" select="$NumPages" />
                            </xsl:call-template>
                      </xsl:if>
                      <xsl:if test="$CurPos = $PageSize and $NumPages &gt; 1 and $PageNumber != $NumPages">
                        <br/>
                        <xsl:call-template name="PagingControls">
                          <xsl:with-param name="Page" select="1" />
                          <xsl:with-param name="NumPages" select="$NumPages" />
                        </xsl:call-template>
                  </xsl:if>
              </xsl:if>
            </center>

A little explanation on the above… I’ve added 3 new variables.

  • PageBeforeLast – this variable calculates the second to last page by taking the total number of pages NumPages, and then subtracts one.
  • CountBeforeLastPage – this variable gets the count of items before the last page by taking the PageBeforeLast variable, and multiplying it by the PageSize, which is the count of items per page.
  • LastPageCount – this variable gets the count of the number of items on the last page, which takes the TotalRecords variable and subtracts the CountBeforeLastPage, so if we have 23 items on the last page instead of 25, we know exactly when to implant the paging control.

Now there are two if conditions after that. The first determines if we are on the last page, and the last count. If we are at the last item on the last page, we will add in the paging control. The second if statement is used for every other page but the last one.

The web part references an untrusted XSL file.

Take a look at this discussion thread for the Extended CQWP by Imtech (the original version for 2007) – http://imtech.codeplex.com/discussions/53870. They are referencing the following error:

image

Now, this is in regards to the XSL options of the Presentation section of the Imtech Content Query Web Part properties.

image

This is very handy – so you can change these on the fly, instead of modifying the Item and Main XSL links in the XML of the web part itself. The bad news – if it is not local to the site, the following code will not work. The assembly for the Imtech CQWP is put into the GAC (if you look at the manfiest.xml file in the WSP), and, the site I was doing this on WAS in full trust mode. However, you will still get this error. To overcome this, you will need to modify the XML of the web part itself to point to your custom XSL stylesheets, if you are not using the out-of-the-box ones, which I do not recommend doing. Keep those as-is, and create new ones. To do this, export the Imtech Content Query Web Part, and open the .webpart file in a text editor. Search for: ItemXslLink and place the link to your customized Item Style XSL there:

<property name="ItemXslLink" type="string">/Style Library/XSL Style Sheets/ImtechItemStyle.xsl</property>

And the same goes for the Main XSL link, locate MainXslLink, and put in the relative URL to your ContentQueryMain XSL file:

<property name="MainXslLink" type="string">/Style Library/XSL Style Sheets/ImtechContentQueryMain.xsl</property>

Then save the file, and you can use it by uploading it to a page, or, make it re-usable by placing it in the web part gallery of your site collection(s).

Limiting the Number of Records Returned

This part is simple, but, I did want to include it. If you have thousands of items in a list, when you enable paging, and if you have your paging set at 25 or 50, you are going to see a lot of page numbers showing up, stretching out the width of your web part if you do not have a fixed width set… so, it does not look so great. Chances are, you do not need to show ALL of the items, just the most recent 50, 100, or a couple of hundred. The way to do this? In addition to using paging, if you limit the number of records returned within the default Content Query Web Part Properties, the only items page will be the number you are returning.

Resources

Microsoft has compiled some great resources on customizing the Content Query Web Part, so I want to share those with you…

And I of course need to add a link here to Heather Solomon’s article on customizing the Content Query Web Part…

Customizing the Content Query Web Part and Custom Item Styles

Speaking at SharePoint Saturday New York on 7/30/11

I am pleased to announce (a bit belated) that I will be presenting at the next SharePoint Saturday New York on July 30th, 2011.  I will be presenting Planning and Configuring Extranets in SharePoint 2010.

Most companies, large or small, require contact and collaboration with external entities, whether they are vendors, clients, or contractors. SharePoint gives us the ability to open up portals for collaboration with these external entities – this session will show you how to accomplish this using SharePoint 2010.

We will review what is required to make SharePoint “open” to the external world, discuss scenarios regarding security and privacy, as well as walk through configuring Forms Based Authentication, Claims Based Authentication, as well as using Business Connectivity Services in SharePoint 2010, to authenticate, and manage our external users.

Once completing this session, you should have a firm grasp on how to configure an extranet environment using SharePoint 2010, as well as what should be considered during the planning of your extranet scenarios.

SharePoint Saturday New York is one of the great SharePoint Saturday events – put on by some great people – Becky Isserman (@MossLover), Jason Gallicchio (@PrincetonSUG), Greg Hurlman (@ghurlman), with Tasha Scott (@TashasEv) coordinating volunteer efforts.

For more information on my session, check out my blog series on the matter here:

Planning and Configuring Extranets in SharePoint 2010–Part 1

Planning and Configuring Extranets in SharePoint 2010–Part 2

Planning and Configuring Extranets in SharePoint 2010-Part 3 “The Environment”

 

I hope to see you in New York! Oh, and by the way, registration is now open! Sign up today as space IS limited! SharePoint Saturday New York