Sharepoint 2010 CQWP: Make the CQWP portable by using tokens to point to the current site instead of static URL
By peter.stilgoe
Target the CQWP to the current site export the CQWP, Edit & replace the WebUrl with below:
<property name="WebUrl" type="string">~Site</property>
To target the CQWP for the Site Collection its currently located on:
<property name="WebUrl" type="string">~sitecollection</property>
More From pstilgoe
Sharepoint CQWP: XSL to link document icon to document and open in edit mode
By peter.stilgoe
The xsl code will display & make the document icon link to the sepcific document & open it in edit mode in your content query webpart:
<a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
<xsl:if test="$ItemsHaveStreams = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of select="@OnClickForWebRendering"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
</xsl:attribute>
</xsl:if>
<img class="image" src="{@DocumentIconImageUrl}" title="" />
</a>
Sharepoint CQWP How to format date from mm/dd/yyyy to UK dd/mm/yyyy
By peter.stilgoe
To format your Sharepoint content query webpart to UK date format do the following:
In your ItemStyle.xsl add the following line to your declarations:
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
Then use the following line to display & format your date field in UK date format:
<xsl:value-of disable-output-escaping="no" select="ddwrt:FormatDate(string(@Modified), 2057, 5)" />
@Modified is your date field that you want to format
Using a CQWP to display items from a link list
By peter.stilgoe
If you point an OOTB CQWP to a Sharepoint Link List it will surface your links but each link will be displayed as (Blank) as its defaulting to display the Title column which is blank, it also links to the Link Item page as opposed to linking throught to the actual Link URL.
To fix this we need to:
1) Tell the CQWP to get the “URL” field from the list
- Add the CQWP to the page where you want to display the link list items
- Export the CQWP to a file (On the CQWP Edit menu click ‘Export’)
- Open the CQWP file in your editor & find
<property name="CommonViewFields" type="string" />
replace this with
<property name="CommonViewFields" type="string">URL,text</property>
(This is telling the CQWP to recognise the ‘URL’ column)
- Save this CQWP file & upload it back to you Web Part Gallery.
2) Create a new itemstyle for a link list that will render the link using the URL field instead of the URL to the link item page
- In your site collection goto
Site Library –> XSL Style Sheets –> ItemStyle.xsl
- Edit ItemStyle.xsl & add the template code below, add this below the last
</xsl:template>
in the file.
<xsl:template name="LinkList" match="Row[@Style='LinkList']" mode="itemstyle"> <xsl:variable name="DisplayTitle"> <xsl:call-template name="OuterTemplate.GetTitle"> <xsl:with-param name="Title" select="@URL"/> <xsl:with-param name="UrlColumnName" select="'URL'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="LinkTarget"> <xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if> </xsl:variable> <div id="linkitem" class="item" > <div class="bullet link-item"> <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/> <a> <xsl:attribute name="href"> <xsl:value-of select="substring-before($DisplayTitle,', ')"> </xsl:value-of> </xsl:attribute> <xsl:attribute name="title"> <xsl:value-of select="@Description"> </xsl:value-of> </xsl:attribute> <xsl:value-of select="substring-after($DisplayTitle,', ')"> </xsl:value-of> </a> </div> </div></xsl:template>
- Save the file & check back in
- Now go back to the page where you want to display links from a Sharepoint Link List & add your new webpart
- Open the webpart properties & goto Presentation –> Styles –> ItemStyle
- You should have the newly added ‘LinkList’ style, select this & click OK
Now your CQWP should be displaying your link list URLs as desired.
Sharepoint 2010: Styling the webpart header title
By peter.stilgoe
To style the text of the webpart header you use the .ms-WPTitle class.
Some webarts automatically make the title of the webpart ie. a link to the specific list its pulling data from.
To style these headers use something like:
/* Webpart Header */
.ms-WPHeader {
BACKGROUND-COLOR: #EEEEEE;
}
.ms-WPHeader td {
border-bottom:1px solid #0066cc;
}
.ms-WPTitle,
.ms-WPTitle a:link,
.ms-WPTitle a:visited {
color:#990066;
}
Unable to add selected web part
By peter.stilgoe
Unable to add selected web part(s)
QueryListPart: A Web Part or Web Form Control on this page cannot be displayed or imported. The type could not be found or it is not registered as safe.
- Make sure the webpart is registered as safe in the web.config
- Make sure the assembly is accessible and in the bin folder
- Make sure the assembly name in the *.webpart definition file, matches the assembly name in the safe control element in web.config
- Make sure you don’t have more than one *.webpart file for the same web part in the web part catalog. This may happen if you changed the name of the *.webpart file.
- Restart IIS to start clean. Attach the debugger to the w3wp.exe process and try to load the page with the rogue web part. This way you can determine the exact location of the assembly you are loading.
- Check if the web part class exists by opening the assembly with reflector. This might sound funny, but in a bigger team, when different versions of assemblies are flying around it is very easy to overlook something and to use the wrong version, which so happens does not contain the web part class at all.
Thanks to http://www.mikhaildikov.com/
How to Prevent users from changing views in Sharepoint
By peter.stilgoe
If you need to prevent users from seeing the view menu allowing them to pick which views they want to use you can remove this easily by:
Browse to the relevant list or library
Click Site Action and select Edit Page
On the Web Part Click edit –> click Modify Shared Web Part
Change Toolbar to either ‘Summary’ or ‘No toolbar’
Now your users won’t be able to view the select ‘View’ dropdown menu
Sharepoint Javascript Error: ‘style.display’ is not null or not an object
By peter.stilgoe
If you are receiving the following error when trying to access the ‘edit’ menu of a webpart on a page:
‘style.display’ is not null or not an object
It is likely that you have some random/extra code in another webpart on the page, this typically happens if you cut & paste text from another location onto the page & it also brings over some formatting chars which upsets Sharepoint. Either:
a) Remove the offending text from another webpart on the page
b) Use something other than IE like Firefox or Google Chrome, typically using another web browser you will be able to edit the troublesome webpart.
More From pstilgoe
How to add extra fields to your CQWP that dont display as standard
By peter.stilgoe
1) Export your Content Query Web part to your desktop
2) Open it with Notepad and look for the following line of code:
3) Change this line to the following, and replace the portion MYINTERNALCOUMNNAME with the internal column name for your column
4) Save your file
5) Import the web part
- Edit page
- Add Web Parts
- Switch to advanced
- Switch from browse to import
- Browse to your file and upload you file
Now when you go to apply a filter, you will see your custom column.
More From pstilgoe
Formatting Text / Questions in Sharepoint Surveys
By peter.stilgoe
If you have ever tried to format text and / or insert line breaks into your questions in sharepoint surveys, you’ll know its not an easy task. However by adding some simple javascript you can format the text in your questions as you want.
Basically at the bottom of your survey page add a Content Editor Webpart & insert the follow script:
You will see the script is mapping your HTML standard HTML command to keywords to trigger your formatting.
So say you wanted your question to appear in italics, you would edit your question as normal but insert the italic keyword triggers ie.
How old are you?
To appear in italics you would write the question as:
startitalic How old are you? enditalic
Now your question will appear in italics and so on……..
If you cant edit your survey page to add you CEWP see the previous post on how to edit this page.
More From pstilgoe
Need to edit a sharepoint page but there is no edit option
By peter.stilgoe
You need to edit a page in Sharepoint but the ‘Edit’ option is greyed out for example on a survey page.
Simply append NewForm.aspx with ?ToolPaneView=2 so it looks like
You now have your page in edit mode so you can add webparts etc
Content Type Toolbar Web Part
By peter.stilgoe
The Content Type Toolbar is a simple add-on that will enhance the use of SharePoint Content Types in large deployments.
The use of content types in SharePoint 2007 has a number of benefits and businesses may spend a considerable amount of time planning and deploying content type to help support their business processes. Unfortunately, the default methods of using content types may not be intuitive for most users who do not have experience with SharePoint. This problem will lead to content types not being used or being neglected by the end users. This can be avoided by training your end users, but it may be sometime before all your users receive the appropriate level of training, so in the meantime the content types are still neglected.



April 19th, 2011
