Content Query Web Part Custom Design
테이블 형식으로 Header 정보 넣기 위해
스타일 라이브러리의 XSL Style Sheets 폴더에서 ContentQuerMain.xsl 파일과 ItemStyle.xsl 파일을 수정해야 합니다.
우선 해당 파일을 다운받습니다.
1. ContentQueryMain.xsl 파일에 코드 추가
우선, <xsl:template name="OuterTemplate.CallItemTemplate"> 안에 아래 두가지의 코드를 캡쳐 이미지1과 같이 추가하시면 됩니다.
<xsl:param name="LastRow" />
<xsl:when test="@Style='CustomStyle'">
<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>
캡쳐 이미지1)
또, <xsl:template name="OuterTemplate.Body">안에 <xsl:call-template name="OuterTemplate.CallItemTemplate"> 태그가 있는데,
그 안에도 아래 캡쳐 이미지2와 같이, <xsl:with-param name="LastRow" select="$LastRow"/> 태그를 추가합니다.
캡쳐 이미지2)
2. ItemStyle.xsl 파일에 코드 추가
수정했던 부분을 삭제하시고 아래 코드를 추가하시면 됩니다.
<xsl:template name="CustomStyle" match="Row[@Style='CustomStyle']" mode="itemstyle">
<xsl:param name="CurPos" />
<xsl:param name="Last" />
<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="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="Rows" select="./@Title"/>
<xsl:variable name="TableStart">
<xsl:if test="$CurPos = 1">
<![CDATA[
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed">
<tr bgcolor="#f9f9f9">
<td width="25%" style="padding:6px;"><b>제목</b></td>
<td width="45%" style="padding:6px;"><b>설명</b></td>
<td width="15%" align="center" style="padding:6px;"><b>수정한 사람</b></td>
<td width="15%" align="right" style="padding:6px;"><b>수정한 날짜</b></td>
</tr>
]]>
</xsl:if>
</xsl:variable>
<xsl:variable name="TableEnd">
<xsl:if test="$CurPos = $Last">
<![CDATA[ </table> ]]>
</xsl:if>
</xsl:variable>
<xsl:value-of select="$TableStart" disable-output-escaping="yes"/>
<tr>
<td width="25%">
<div id="linkitem" class="item link-item bullet">
<nobr style="text-overflow:ellipsis;overflow-x:hidden;width:95%">
<a href="{$SafeLinkUrl}" target="_blank" title="{@Title}">
<xsl:value-of select="$DisplayTitle"/>
</a>
</nobr>
</div>
</td>
<td width="45%" title="{@Description}">
<nobr style="text-overflow:ellipsis;overflow-x:hidden;width:95%">
<xsl:value-of select="@Description" />
</nobr>
</td>
<td width="15%" align="center" title="{@Editor}">
<nobr style="text-overflow:ellipsis;overflow-x:hidden;width:95%">
<xsl:value-of select="@Editor" />
</nobr>
</td>
<td width="15%" align="right" title="{substring(@Modified, 0, 11)}" style="padding-right:7px;">
<nobr style="text-overflow:ellipsis;overflow-x:hidden;width:95%">
<xsl:value-of select="substring(@Modified, 0, 11)" />
</nobr>
</td>
</tr>
<xsl:value-of select="$TableEnd" disable-output-escaping="yes"/>
</xsl:template>
3. 결과 화면