Dear All,
Here is the easiest way to make add custom column under your content query web part and then you can format it as you want.
Step 1:
Open Sharepoint design
Step 2:
Open site for sharepoint parent site collection
Step 3:
Locate the following folder
Style Library > XLS Style Sheets
Step 4:
Open "ItemStyle.xsl" file
Add the custom style sheet as you want
Here is the easiest way to make add custom column under your content query web part and then you can format it as you want.
Step 1:
Open Sharepoint design
Step 2:
Open site for sharepoint parent site collection
Step 3:
Locate the following folder
Style Library > XLS Style Sheets
Step 4:
Open "ItemStyle.xsl" file
Add the custom style sheet as you want
<xsl:template name="[Your Style Name]"
match="Row[@Style='[Your Style Name]']" mode="itemstyle">
<xsl:param name="CurPos" />
<xsl:variable name="SafeLinkUrl">
<xsl:call-template
name="OuterTemplate.GetSafeLink">
<xsl:with-param
name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="SafeImageUrl">
<xsl:call-template
name="OuterTemplate.GetSafeStaticUrl">
<xsl:with-param
name="UrlColumnName" select="'ImageUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param
name="Title" select="@Title"/>
<xsl:with-param
name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
Here you define your custom column input
<xsl:variable name="[Your Column Variable Name]">
<xsl:value-of select="@[Your Column Variable Name]" />
</xsl:variable>
Here you Call this under your template
<xsl:value-of select="$[Your Column Variable Name]"></xsl:value-of>
</xsl:template>
If you need to add any HTML between these tags you can like
<div class="[Your Class Name"]>
<xsl:value-of select="$[Your Column Variable Name]"></xsl:value-of>
</div>
I hope it will save your time
Just for reference i am putting the complete template below
Just for reference i am putting the complete template below
<xsl:template name="NewsPagelist"
match="Row[@Style='NewsPagelist']" mode="itemstyle">
<xsl:param name="CurPos" />
<xsl:variable name="SafeLinkUrl">
<xsl:call-template
name="OuterTemplate.GetSafeLink">
<xsl:with-param
name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="SafeImageUrl">
<xsl:call-template
name="OuterTemplate.GetSafeStaticUrl">
<xsl:with-param
name="UrlColumnName" select="'ImageUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param
name="Title" select="@Title"/>
<xsl:with-param
name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="ArticleDate">
<!--
<xsl:value-of select="ddwrt:FormatDateTime(string($ArticleDate), 1025,
'MMMM dd, yyyy')" />
<xsl:value-of select="@ArticleDate" />
<xsl:value-of select="ddwrt:FormatDateTime(string($ArticleDate) ,1025
,'yyyy/MM/dd')" />
!-->
<xsl:value-of select="@ArticleDate" />
</xsl:variable>
<xsl:variable name="NewsDescription">
<xsl:value-of select="@NewsDescription" />
</xsl:variable>
<xsl:variable name="NewsCategory">
<xsl:value-of select="@NewsCategory" />
</xsl:variable>
<div id="newsitem">
<div id="newsimage">
<a style="color: rgb(0, 0, 0); text-decoration: none;"
href="{$SafeLinkUrl}">
<img style="border: currentColor; border-style:none;"
width="140px" height="140px" alt=""
src="{$SafeImageUrl}"></img>
</a>
</div>
<div id="newsDetail">
<div id="newstitle">
<a href="{$SafeLinkUrl}">
<xsl:value-of
select="$DisplayTitle"/>
</a>
</div>
<div
id="newsDescription">
<xsl:value-of select="$NewsDescription"></xsl:value-of>
</div>
<div id="newsInfo">
<div id="newsdate">
<!--
<xsl:value-of select="$ArticleDate"/>
!-->
<xsl:value-of select="ddwrt:FormatDateTime(string($ArticleDate),
1033, 'MMMM dd, yyyy')" />
</div>
<div id="newscategory">
<xsl:value-of select="$NewsCategory">
</xsl:value-of>
</div>
<div id="newsmore">
<a href="{$SafeLinkUrl}">
<img src="/ar-sa/PublishingImages/GACA-ES-In_17.gif"
alt=""></img>
</a>
</div>
</div>
</div>
</div>
<center style="clear:both">
<xsl:if test="$PageSize > 0">
<xsl:variable name="NumPages" select="ceiling($TotalRecords
div $PageSize)"/>
<xsl:if test="$NumPages > 1">
<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-AR">
<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 > 1 and
$PageNumber != $NumPages">
<br/>
<xsl:call-template name="PagingControls-AR">
<xsl:with-param name="Page" select="1" />
<xsl:with-param name="NumPages" select="$NumPages" />
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:if>
</center>
</xsl:template>
Regards
Rashid Imran Bilgrami
81
ReplyDeleteHi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Online Training from India. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
JavaScript Online Training from India