0

How to Get web/site/List/ Tittle in CQWP.

Hi

Explain you here How to Get web/site/List/ Title in CQWP.

Once I got this requirement How to get Web Title or web title where Item is coming and Bind in CQWP

I have done lot`s of R&D For that but there no provision to get web Title or List Title Direct From ItemStyle.xml

It is Possible but How Let `s See

  • Open your .webpart File
  • Find “ViewFieldsOverride” Property
  • In this Property we have to override SharePoint default column like (created, Modified)+your view Column that you use to display in CQWP
  • But Best Practice is just Taking all Field and put it in to this in My Case I have use Task List
  • Now if you want to get Web Title then Define “<ProjectProperty Name=”Title” />”  ,This will return you web/Site Title
  • Same as if you want to get List Title <ListProperty Name=”Title” /> in same manner you can notice in below code
  • Remarks Must Define your FieldRef and Properties inside  <![CDATA[ ]]>  ok now save and upload your web part

<property name=”ViewFieldsOverride” type=”string”><![CDATA[
<FieldRef ID=”{fa564e0f-0c70-4ab9-b863-0177e6ddd247}” Nullable=”True” Type=”Text” />
<FieldRef ID=”{64cd368d-2f95-4bfc-a1f9-8d4324ecb007}” Nullable=”True” Type=”DateTime” />
<FieldRef ID=”{cd21b4c2-6841-4f9e-a23a-738a65f99889}” Nullable=”True” Type=”DateTime” />
<FieldRef ID=”{53101f38-dd2e-458c-b245-0c236cc13d1a}” Nullable=”True” Type=”User” />
<FieldRef ID=”{d2311440-1ed6-46ea-b46d-daa643dc3886}” Nullable=”True” Type=”Number” />
<FieldRef ID=”{7662cd2c-f069-4dba-9e35-082cf976e170}” Nullable=”True” Type=”Note” />
<FieldRef ID=”{c3a92d97-2b77-4a25-9698-3ab54874bc6f}” Nullable=”True” Type=”Lookup” />
<FieldRef ID=”{a8eb573e-9e11-481a-a8c9-1104a54b2fbd}” Nullable=”True” Type=”Choice” />
<FieldRef ID=”{c15b34c3-ce7d-490a-b133-3f4de8801b76}” Nullable=”True” Type=”Choice” />
<FieldRef ID=”{8c06beca-0777-48f7-91c7-6da68bc07b69}” Nullable=”True” Type=”DateTime” />
<FieldRef ID=”{1df5e554-ec7e-46a6-901d-d85a3881cb18}” Nullable=”True” Type=”User” />
<FieldRef ID=”{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}” Nullable=”True” Type=”DateTime” />
<FieldRef ID=”{d31655d1-1d5b-4511-95a1-7a09e9b75bf2}” Nullable=”True” Type=”User” />
<FieldRef Name=”PublishingRollupImage” Nullable=”True” Type=”Image” />
<FieldRef Name=”_Level” Nullable=”True” Type=”Number” />
<FieldRef Name=”Comments” Nullable=”True” Type=”Note” />
<ListProperty Name=”Title” /><ProjectProperty Name=”Title” />
]]></property>

-Now open you ItemStyle.xml

you can access Project title  and List Title by

<xsl:value-of select=”ProjectProperty.Title”/>  //Get Web Title

<xsl:value-of select=”ListProperty.Title”/>   // Get List Tittle

Remark Once you modified your webpart ovverride List in  <ProjectProperty Name=”Title” />

in ItemStyle.xslt you will not Get absolute URL [&SiteUrl,$LinkUrl,$PageUrl]

you will get break url in these object so it is tuff to manipulate this URL and get Absolute URL

if you want to get URL For Item you can define <ProjectProperty Name=”Url” /> inside ViewFieldsOverride

now you can access url in Item Style <xsl:value-of select=”ProjectProperty.Url”/>

Hope you Get your issue Resolve from this

Thanks SPS

Advertisements
0

Apply Slider in Content Query Web part(CQWP) using XSL

Hello everyone ,

I hope, You are well and doing good.

What is CQWP?

SharePoint Content Query Web Part (CQWP) is a powerful tool to display aggregated content from various SharePoint pages, lists and libraries .

Note : More Information regarding cqwp 

https://msdn.microsoft.com/en-us/library/ff650512.aspx


Now i am here to explain you how to get List item from SharePoint list and library and display it in Content Query Web part  with attractive manner and  user friendliness.

Now, i have a question .How can i make it attractive manner ? Right . Let me Explain You. I want to tell you that , In attractive manner means put some animation,Give effect with sliding etc etc.

Business Requirement :

I have one share point list name with NewsList. Now i want to display data in “Newslist” on my home page with sliding effect. E.g   I have 5 records in NewsList and I have to display Top 3 records in CQWP . Only one record display in one slide.Slider has to be automatically working . Display field of NewslIst is “Title”, “Date” and “NewsContent” . If  “NewsContent” is more than 40 Characters , than Only 40 characters can be in slider and must be a link Read More… Below that.

I  Hope , Everyone is clear with Requirement. Now i am going to describe solution to fulfill this requirement. There is two way : 1)Add Script Editor to with content query web part and load necessary .js file to share point . 2) Add and load .js file using XSL . I  have prefer second way for get output Solution : Step :1

  •  You have to create one list or library in your share point site.
  • After that you have to select content Query Web part in your page where you want to implement slider

Note: If you are working on TeamSite than you have to activate two features to use CQWP .  1) SharePoint Server publishing infrastructure.(Site level) 2) SharePoint server publishing(Web level) But if you are using Publishing Site than no worry . Two features automatically activated by share point.

  •  Now, You have to configure such setting to get list records in CQWP.

Step : 1

CQWP Steps to open CQWP Tool Part : Edit Page –> Click on Edit Web part –> Tool part is open in left side of your page

Now you have to set path of resource from which you want to take data and show it in to CQWP. Either it is list or Library.

Step : 2

You have to  Export webpart.

Steps to export webpart.

Edit Page -> Edit Webpart ->Click on Export Button ->Web part exported successfully in your local macNow you h

Capture1

Open Exported .webpart file in share-point designer or in other tool like note or notepad++.

Step : 3

You have to change value of two properties in .webpart. You have to change value of this properties if you are using your custom “itemstyle.xsl” or “contentquerymain.xsl” . if you are using default file than you have not to change it.

1)ItemXslLink   2)MainXslLink

Set your itemstyle.xsl file path in itemslLink and contentquerymain.xsl in Mainxsllink. You can see in image .

Capture4

Close the.webpart fie and upload webpart in sharepoint.

Edit Page -> Insert -> Click on webpart ->Click on upload webpart -> select webpart -> Click on Upload 

Upload webpart

Step : 4

Now open Itemstyle.xsl To put your login for slider.

I had use Jassor.slider to display data with sliding . You can use any other slider to display data.

Here , Create your custom template to display data in ItemStyle.xsl. i have created SliderTemplate . Here CurPos and LastRaw is two parameter to give some css  or display data in some manner.

This Two parameter is define in contentmain.xsl.

Contentmain.xsl

Capture5

ItemStyle.xsl

Capture7

Capture8

Capture9Capture10Capture11


Note :Why is it necessary to create and call “removemarkup”?

If you are direct get data from body field in announcement list than you can get string with some html tag and special character which is not understandable by non-technical person. So we have to remove this type of tag and special character

So i have to remove this type of tags using “removeMarkUp” template. you can use it as per your requirement.

Capture2

Now  Open your site . open Wenpart Tool panal . and check your custom template is present or not.

Capture2

If Template is displayed in drop down . That means you have successfully  configures custom template to the web part. You can see slider on page with necessary data.


Kindly contact me if have any query regarding this post.

Happy Coding 🙂