Showing posts with label xslt. Show all posts
Showing posts with label xslt. Show all posts

Tuesday, May 30, 2017

Sharepoint Designer 2013, XSLT List View Options ribbon option is not showing

Sharepoint Designer 2013, XSLT List View Options ribbon option is not showing


I have an ordinary Wiki Page, also tried making an Article Page.
Once this page is made, I add an XsltListViewWebPart that points to a list, which is fine, this is added from the sharepoint web site page edit.
When I open it up in Sharepoint Designer 2013, and select the XsltListViewWebPart the ribbon does not contain the List View Options listview for me to edit the filters, parameters etc.
What I do notice is, when I add the XsltListViewWebPart from inside the Sharepoint Designer 2013, I see the ribbon section fine. However once I save changes on the page, close it and re-open it, same issue, can't see that ribbon section.

The solution :
Go to Edit web part and select "Miscellaneous" property and click on Server Render checkbox.
then you will able to see that in designer
hope it helps!

Monday, May 4, 2015

Custom date formats with XSLT

Custom date formats with XSLT

The default format of a date field is something like 2012-01-01 00:00:00 – this is dependent on the language of the SharePoint installation. It is a very common requirement to display a date field in a different format.
Example
 2012-01-01 00:00:00

Example code
<xsl:value-of select="@ArticleStartDate"/>

Solution

1. Open the ItemStyle.xsl in SharePoint Designer or your favorite editor.
2. To be able to use the FormatDate function, add the DDWRT name space reference in the top section.
xmlns:ddwrt=“http://schemas.microsoft.com/WebParts/v2/DataView/runtime”
3. Use the code below to display the date field in the location you want the date shown. Every language has a different country code. The example in this article uses the UK country code (1033).
<xsl:value-of select="ddwrt:FormatDateTime(string(@ArticleStartDate) ,1033 ,'dd-mm-yyyy')"/>

Result
 01-01-2012
There are many different ways to display dates, take a look on MSDN for all the format specifiers. The country codes (supported locale identifiers) can also be found on MSDN.
Hope this help,
Oumaima

Reference list for SharePoint internal field names

Reference list for SharePoint internal field names

Much used reprinting of list of fields with internal names for easy reference:

Document Library fields
Display NameInternal NameGUIDType
IDID{1d22ea11-1e32-424e-89ab-9fedbadb6ce1}Counter
Content Type IDContentTypeId{03e45e84-1992-4d42-9116-26f756012634}ContentTypeId
Content TypeContentType{c042a256-787d-4a6f-8a8a-cf6ab767f12d}Text
CreatedCreated{8c06beca-0777-48f7-91c7-6da68bc07b69}DateTime
Created ByAuthor{1df5e554-ec7e-46a6-901d-d85a3881cb18}User
ModifiedModified{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}DateTime
Modified ByEditor{d31655d1-1d5b-4511-95a1-7a09e9b75bf2}User
Has Copy Destinations_HasCopyDestinations{26d0756c-986a-48a7-af35-bf18ab85ff4a}Boolean
Copy Source_CopySource{6b4e226d-3d88-4a36-808d-a129bf52bccf}Text
Approval Status_ModerationStatus{fdc3b2ed-5bf2-4835-a4bc-b885f3396a61}ModStat
Approver Comments_ModerationComments{34ad21eb-75bd-4544-8c73-0e08330291fe}Note
URL PathFileRef{94f89715-e097-4e8b-ba79-ea02aa8b7adb}Lookup
PathFileDirRef{56605df6-8fa1-47e4-a04c-5b384d59609f}Lookup
ModifiedLast_x0020_Modified{173f76c8-aebd-446a-9bc9-769a2bd2c18f}Lookup
CreatedCreated_x0020_Date{998b5cff-4a35-47a7-92f3-3914aa6aa4a2}Lookup
File SizeFile_x0020_Size{8fca95c0-9b7d-456f-8dae-b41ee2728b85}Lookup
Item TypeFSObjType{30bb605f-5bae-48fe-b4e3-1f81d9772af9}Lookup
Effective Permissions MaskPermMask{ba3c27ee-4791-4867-8821-ff99000bac98}Computed
ID of the User who has the item Checked OutCheckedOutUserId{a7b731a3-1df1-4d74-a5c6-e2efba617ae2}Lookup
Is Checked out to localIsCheckedoutToLocal{cfaabd0f-bdbd-4bc2-b375-1e779e2cad08}Lookup
Checked Out ToCheckoutUser{3881510a-4e4a-4ee8-b102-8ee8e2d0dd4b}User
NameFileLeafRef{8553196d-ec8d-4564-9861-3dbe931050c8}File
Unique IdUniqueId{4b7403de-8d94-43e8-9f0f-137a3e298126}Lookup
ProgIdProgId{c5c4b81c-f1d9-4b43-a6a2-090df32ebb68}Lookup
ScopeIdScopeId{dddd2420-b270-4735-93b5-92b713d0944d}Lookup
Virus StatusVirusStatus{4a389cb9-54dd-4287-a71a-90ff362028bc}Lookup
Checked Out ToCheckedOutTitle{9d4adc35-7cc8-498c-8424-ee5fd541e43a}Lookup
Check In Comment_CheckinComment{58014f77-5463-437b-ab67-eec79532da67}Lookup
Checked Out ToLinkCheckedOutTitle{e2a15dfd-6ab8-4aec-91ab-02f6b64045b0}Computed
Document Modified ByModified_x0020_By{822c78e3-1ea9-4943-b449-57863ad33ca9}Text
Document Created ByCreated_x0020_By{4dd7e525-8d6b-4cb4-9d3e-44ee25f973eb}Text
File TypeFile_x0020_Type{39360f11-34cf-4356-9945-25c44e68dade}Text
HTML File TypeHTML_x0020_File_x0020_Type{0c5e0085-eb30-494b-9cdd-ece1d3c649a2}Text
Source Url_SourceUrl{c63a459d-54ba-4ab7-933a-dcf1c6fadec2}Text
Shared File Index_SharedFileIndex{034998e9-bf1c-4288-bbbd-00eacfc64410}Text
Edit Menu Table Start_EditMenuTableStart{3c6303be-e21f-4366-80d7-d6d0a3b22c7a}Computed
Edit Menu Table End_EditMenuTableEnd{2ea78cef-1bf9-4019-960a-02c41636cb47}Computed
NameLinkFilenameNoMenu{9d30f126-ba48-446b-b8f9-83745f322ebe}Computed
NameLinkFilename{5cc6dc79-3710-4374-b433-61cb4a686c12}Computed
TypeDocIcon{081c6e4c-5c14-4f20-b23e-1a71ceb6a67c}Computed
Server Relative URLServerUrl{105f76ce-724a-4bba-aece-f81f2fce58f5}Computed
Encoded Absolute URLEncodedAbsUrl{7177cfc7-f399-4d4d-905d-37dd51bc90bf}Computed
NameBaseName{7615464b-559e-4302-b8e2-8f440b913101}Computed
File SizeFileSizeDisplay{78a07ba4-bda8-4357-9e0f-580d64487583}Computed
Property BagMetaInfo{687c7f94-686a-42d3-9b67-2782eac4b4f8}Lookup
Level_Level{43bdd51b-3c5b-4e78-90a8-fb2087f71e70}Integer
Is Current Version_IsCurrentVersion{c101c3e7-122d-4d4d-bc34-58e94a38c816}Boolean
SelectSelectTitle{b1f7969b-ea65-42e1-8b54-b588292635f2}Computed
SelectSelectFilename{5f47e085-2150-41dc-b661-442f3027f552}Computed
EditEdit{503f1caa-358e-4918-9094-4a2cdc4bc034}Computed
owshiddenversionowshiddenversion{d4e44a66-ee3a-4d02-88c9-4ec5ff3f4cd5}Integer
UI Version_UIVersion{7841bf41-43d0-4434-9f50-a673baef7631}Integer
Version_UIVersionString{dce8262a-3ae9-45aa-aab4-83bd75fb738a}Text
Instance IDInstanceID{50a54da4-1528-4e67-954a-e2d24f1e9efb}Integer
OrderOrder{ca4addac-796f-4b23-b093-d2a3f65c0774}Number
GUIDGUID{ae069f25-3ac2-4256-b9c3-15dbc15da0e0}Guid
Workflow VersionWorkflowVersion{f1e020bc-ba26-443f-bf2f-b68715017bbc}Integer
Workflow Instance IDWorkflowInstanceID{de8beacf-5505-47cd-80a6-aa44e7ffe2f4}Guid
Source Version (Converted Document)ParentVersionString{bc1a8efb-0f4c-49f8-a38f-7fe22af3d3e0}Lookup
Source Name (Converted Document)ParentLeafName{774eab3a-855f-4a34-99da-69dc21043bec}Lookup
TitleTitle{fa564e0f-0c70-4ab9-b863-0177e6ddd247}Text
Template LinkTemplateUrl{4b1bf6c6-4f39-45ac-acd5-16fe7a214e5e}Text
Html File Linkxd_ProgID{cd1ecb9f-dd4e-4f29-ab9e-e9ff40048d64}Text
Is Signedxd_Signature{fbf29b2d-cae5-49aa-8e0a-29955b540122}Boolean
MergeCombine{e52012a0-51eb-4c0c-8dfb-9b8a0ebedcb6}Computed
RelinkRepairDocument{5d36727b-bcb2-47d2-a231-1f0bc63b7439}Computed

 Custom list fields 
Display NameInternal NameGUIDType
IDID{1d22ea11-1e32-424e-89ab-9fedbadb6ce1}Counter
Content Type IDContentTypeId{03e45e84-1992-4d42-9116-26f756012634}ContentTypeId
Content TypeContentType{c042a256-787d-4a6f-8a8a-cf6ab767f12d}Text
TitleTitle{fa564e0f-0c70-4ab9-b863-0177e6ddd247}Text
ModifiedModified{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}DateTime
CreatedCreated{8c06beca-0777-48f7-91c7-6da68bc07b69}DateTime
Created ByAuthor{1df5e554-ec7e-46a6-901d-d85a3881cb18}User
Modified ByEditor{d31655d1-1d5b-4511-95a1-7a09e9b75bf2}User
Has Copy Destinations_HasCopyDestinations{26d0756c-986a-48a7-af35-bf18ab85ff4a}Boolean
Copy Source_CopySource{6b4e226d-3d88-4a36-808d-a129bf52bccf}Text
owshiddenversionowshiddenversion{d4e44a66-ee3a-4d02-88c9-4ec5ff3f4cd5}Integer
Workflow VersionWorkflowVersion{f1e020bc-ba26-443f-bf2f-b68715017bbc}Integer
UI Version_UIVersion{7841bf41-43d0-4434-9f50-a673baef7631}Integer
Version_UIVersionString{dce8262a-3ae9-45aa-aab4-83bd75fb738a}Text
AttachmentsAttachments{67df98f4-9dec-48ff-a553-29bece9c5bf4}Attachments
Approval Status_ModerationStatus{fdc3b2ed-5bf2-4835-a4bc-b885f3396a61}ModStat
Approver Comments_ModerationComments{34ad21eb-75bd-4544-8c73-0e08330291fe}Note
EditEdit{503f1caa-358e-4918-9094-4a2cdc4bc034}Computed
TitleLinkTitleNoMenu{bc91a437-52e7-49e1-8c4e-4698904b2b6d}Computed
LinkFilenameNoMenu
TitleLinkTitle{82642ec8-ef9b-478f-acf9-31f7d45fbc31}Computed
SelectSelectTitle{b1f7969b-ea65-42e1-8b54-b588292635f2}Computed
Instance IDInstanceID{50a54da4-1528-4e67-954a-e2d24f1e9efb}Integer
OrderOrder{ca4addac-796f-4b23-b093-d2a3f65c0774}Number
GUIDGUID{ae069f25-3ac2-4256-b9c3-15dbc15da0e0}Guid
Workflow Instance IDWorkflowInstanceID{de8beacf-5505-47cd-80a6-aa44e7ffe2f4}Guid
URL PathFileRef{94f89715-e097-4e8b-ba79-ea02aa8b7adb}Lookup
PathFileDirRef{56605df6-8fa1-47e4-a04c-5b384d59609f}Lookup
ModifiedLast_x0020_Modified{173f76c8-aebd-446a-9bc9-769a2bd2c18f}Lookup
CreatedCreated_x0020_Date{998b5cff-4a35-47a7-92f3-3914aa6aa4a2}Lookup
Item TypeFSObjType{30bb605f-5bae-48fe-b4e3-1f81d9772af9}Lookup
Effective Permissions MaskPermMask{ba3c27ee-4791-4867-8821-ff99000bac98}Computed
NameFileLeafRef{8553196d-ec8d-4564-9861-3dbe931050c8}File
Unique IdUniqueId{4b7403de-8d94-43e8-9f0f-137a3e298126}Lookup
ProgIdProgId{c5c4b81c-f1d9-4b43-a6a2-090df32ebb68}Lookup
ScopeIdScopeId{dddd2420-b270-4735-93b5-92b713d0944d}Lookup
File TypeFile_x0020_Type{39360f11-34cf-4356-9945-25c44e68dade}Text
HTML File TypeHTML_x0020_File_x0020_Type{4ef1b78f-fdba-48dc-b8ab-3fa06a0c9804}Computed
Edit Menu Table Start_EditMenuTableStart{3c6303be-e21f-4366-80d7-d6d0a3b22c7a}Computed
Edit Menu Table End_EditMenuTableEnd{2ea78cef-1bf9-4019-960a-02c41636cb47}Computed
NameLinkFilenameNoMenu{9d30f126-ba48-446b-b8f9-83745f322ebe}Computed
NameLinkFilename{5cc6dc79-3710-4374-b433-61cb4a686c12}Computed
TypeDocIcon{081c6e4c-5c14-4f20-b23e-1a71ceb6a67c}Computed
Server Relative URLServerUrl{105f76ce-724a-4bba-aece-f81f2fce58f5}Computed
Encoded Absolute URLEncodedAbsUrl{7177cfc7-f399-4d4d-905d-37dd51bc90bf}Computed
File NameBaseName{7615464b-559e-4302-b8e2-8f440b913101}Computed
Property BagMetaInfo{687c7f94-686a-42d3-9b67-2782eac4b4f8}Lookup
Level_Level{43bdd51b-3c5b-4e78-90a8-fb2087f71e70}Integer
Is Current Version_IsCurrentVersion{c101c3e7-122d-4d4d-bc34-58e94a38c816}Boolean

Friday, October 10, 2014

SharePoint Custom Grouping with XSLT

Sharepoint Custom Grouping With XSLT

For SharePoint solution where the look and feel or clean code is very important we often create custom header.xslt ContentQueryMain.xslt and ItemStyle.xstl files. The files are almost completely empty to provide us with maximal control. This also means we need to recreate functionality that normally works by default. A good example is the ability to group the results.
Solution
1. Create the custom XSLT files and link the files to the Content Query Web Part.
2. The following code is a complete example of a custom Content Query Main XSLT file. This code generates grouping.

<xsl:stylesheet
    version="1.0"
    exclude-result-prefixes="x xsl cmswrt cbq" 
    xmlns:x="http://www.w3.org/2001/XMLSchema"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:cmswrt="http://schemas.microsoft.com/WebPart/v3/Publishing/runtime"
    xmlns:cbq="urn:schemas-microsoft-com:ContentByQueryWebPart">
    <xsl:output method="xml" indent="no" media-type="text/html" omit-xml-declaration="yes"/>

  <xsl:key name="Grouping" match="Row" use="@GroupingColumn" />

  <xsl:template match="/">
 <xsl:for-each select="/dsQueryResponse/Rows/Row[generate-id(.)=generate-id(key('Grouping',@GroupingColumn))]/@GroupingColumn">
  <xsl:sort />
        <xsl:value-of select="."/>
        <xsl:for-each select="key('Grouping', .)">
         <br /><xsl:value-of select="@Title" />
         </xsl:for-each>
        <br/>
      </xsl:for-each>     
    </xsl:template>
</xsl:stylesheet>
3. Change the XSLT where needed
Result
CQWP Custom Grouping


Content Query Web Parts and the CommonViewFields Property

Content Query Web Parts and the CommonViewFields Property   



Much of my job as a SharePoint consultant working in the Web Content Management discipline is the configuring of web parts. One of the most popular web parts has to be the Content Query Web Part. This web part allows you to roll up different kinds of content at the site collection, site, or list level and have full control of the styling of the rollup list through XSL.
Although the Content Query Web Part is very easy to use, it can be challenging getting all of the information available which is what this blog article is all about. By default, fields such as Title, Descriptions, and URL are provided by default. The challenge arises when you need to display more information than what the default fields provide. An example of this would be the case where a custom date field, let's call it NewDate, would need to be included as part of the rollup.
Now, if we tried to call NewDate directly from the XSL, it would simply print out nothing. This is because the web part doesn't know about NewDate.
To do this, we need to configure the web part to tell it about our New Field.
This is a simple x step process.
  1. First, you will need to export the web part so that its properties can be edited.
    In edit mode on the CQWP, select Edit -> Export

  1. After opening the exported file, locate the CommonViewFields property.



    By default, it will be blank. Adding additional fields to this property will make them available for display.
  2. To continue with the example, we will need to add our new field, NewDate, to the CommonViewFields property. The format of this property is [Internal Field Name],[Data Type Name]. It is important to note that the name is the internal field name and not necessarily the name you gave to the list. The best way to determine the internal field name is to go to the List or Content Type settings and click on the new field. The internal field name will be the last query string argument in the URL.
    In our example, you would add "NewDate,DateTime" to the property as shown below:

    In this example, our field type is DateTime. For a complete list of field types, see this MSDN article: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfieldtype.aspx
  3. The final step is to save the web part file and import back into the page. The field, NewDate, is now available and can be successfully referenced in the appropriate XSL files.

Sharepoint Designer 2013, XSLT List View Options ribbon option is not showing

Sharepoint Designer 2013, XSLT List View Options ribbon option is not showing I have an ordinary Wiki Page, also tried making an Article...