Showing multiple columns in content query web part was what I was working on this week in our SharePoint 2013 environment.
This post is a quick summery of what I learned through the whole work.
And change it to:
Now that we pass the parameter we also have to change the template to accept the parameter.
Go to lines and you see the “CallItemTemplate”. Copy the second line and past it directly beneath it and make it look like this:
Because we want to use this within our custom item template we also
have give the parameter through to the template by adding a when
statement just before the <xsl:otherwise> within the
CallItemTemplate:
In this statement we specify that it only has to pass-through the
parameter when the item template is
and my final custom code is like this. I tried to use SharePoint light banded rows style to have a better view. Don’t forget there’s a little customize for ContentMainQuery.xsl as mentioned above.
This post is a quick summery of what I learned through the whole work.
- My platform is SharePoint 2013
- I’m using content type syndication, so the hub is another site collection and in a second site collection I’m going to use CQWP based on a specific content type with its own site columns
- Step1, to know what itemstyle.xsl is and how it works. then customize it
- step2, to know what ContentQueryMain.xsl is and how it works, then customize it
- A trick to insert CQWP on your SharePoint web page
< xsl:call-template name = "OuterTemplate.CallItemTemplate" > < xsl:with-param name = "CurPosition" select = "$CurPosition" /> </ xsl:call-template > |
< xsl:call-template name = "OuterTemplate.CallItemTemplate" > < xsl:with-param name = "CurPosition" select = "$CurPosition" /> < xsl:with-param name = "LastRow" select = "$LastRow" /> </ xsl:call-template > |
Go to lines and you see the “CallItemTemplate”. Copy the second line and past it directly beneath it and make it look like this:
< xsl:template name = "OuterTemplate.CallItemTemplate" > < xsl:param name = "CurPosition" /> < xsl:param name = "LastRow" /> |
< xsl:when test = "@Style='
> < xsl:apply-templates select = "." mode = "itemstyle" > < xsl:with-param name = "CurPos" select = "$CurPosition" /> < xsl:with-param name = "Last" select = "$LastRow" /> </ xsl:apply-templates > </ xsl:when > |
ProjectsReport
. So our custom template is
going to be called “ProjectsReport
”.and my final custom code is like this. I tried to use SharePoint light banded rows style to have a better view. Don’t forget there’s a little customize for ContentMainQuery.xsl as mentioned above.
< xsl:template name = "ProjectsReport" match = "Row[@Style='ProjectsReport']" mode = "itemstyle" > < xsl:param name = "CurPos" /> < xsl:param name = "Last" />
< xsl:variable name = "tableStart" > < xsl:if test = "$CurPos = 1" > <![CDATA[ <table width="100%" class="ms-rteTable-6" cellpadding="1" cellspacing="0">
<tr class=""> <th class="">Name</th> <th class="">Client</th> <th class="">Status Summary</th> <th class="">Project Phase</th> <th class="">This Reporting Period</th> <th class="">Next Reporting Period</th> <th class="">Key Issues and Risks</th> </tr>]]> </ xsl:if > </ xsl:variable > < xsl:variable name = "tableEnd" > < xsl:if test = "$CurPos = $Last" > <![CDATA[ </table> ]]> </ xsl:if > </ xsl:variable > < xsl:variable name = "rowStart" > < xsl:if test = "$CurPos mod 2 = 0" > <![CDATA[ <tr class="ms-rteTableEvenRow-6"> ]]> </ xsl:if > < xsl:if test = "$CurPos mod 2 != 0" > <![CDATA[ <tr class="ms-rteTableOddRow-6"> ]]> </ xsl:if > </ xsl:variable > < xsl:variable name = "rowEnd" > <![CDATA[ </tr> ]]> </ xsl:variable > < xsl:value-of select = "$tableStart" disable-output-escaping = "yes" /> < xsl:value-of select = "$rowStart" disable-output-escaping = "yes" /> < td > < xsl:value-of select = "@ProjectName" /> </ td > < td > < xsl:value-of select = "@ProjectClient" /> </ td > < td > < xsl:value-of select = "@StatusSummary" disable-output-escaping = "yes" /> </ td > < td > < xsl:value-of select = "@ProjectPhase" /> </ td > < td > < xsl:value-of select = "@ThisReportingPeriod" disable-output-escaping = "yes" /> </ td > < td > < xsl:value-of select = "@NextReportingPeriod" disable-output-escaping = "yes" /> </ td > < td > < xsl:value-of select = "@KeyIssuesRisks" disable-output-escaping = "yes" /> </ td > < xsl:value-of select = "rowEnd" /> < xsl:value-of select = "$tableEnd" disable-output-escaping = "yes" /> </ xsl:template > |
0 comments:
Post a Comment