Pergunta

I do not have a formal knowledge of XSLT so my successes are with attempts.

I would like to know one information once for all. Sometimes I need a slight modification on the templates such as the 'title and description' (internal name 'no image') with a date field in place of the description.

I get date and time while I just want to have the date.

I have written this in a copy of the template (only the portion relevant to the date, the rest is ok.

            <div class="Description">
          <xsl:value-of select="ddwrt:FormatDate(@Date, 2057, 3)" />
        </div>

and I get that the CQWP is broken.

  1. do I have to keep the class description? (line 1)
  2. is the ddwrt correct? what do I have to write after @? (line 2) My Date in the source list is called 'Action delivery date'

I have also copied on top

xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime

UPDATE

enter image description here

Foi útil?

Solução

do I have to keep the class description?

this does not affect the value of XSL, it's a div tag that use description class for only design/display purpose

is the ddwrt correct?

yes it's correct , 2057 denote to LCID that is English for united kingdom , and 3 is format flag that display date as this format 23 March 2016

Also, you can replace it with 1033 for English-United State .

enter image description here

what do I have to write after @? (line 2) My Date in the source list is called 'Action delivery date'

You should get the internal name of 'Action delivery date' and but it after @

so space should be replaced by _x0020_ so the internal name should look like

Action_x0020_delivery_x0020_date

And the final ddwrt

  <xsl:value-of select="ddwrt:FormatDate(@Action_x0020_delivery_x0020_date, 2057, 3)" />

Note : to get the internal name > open your list > list settings > click on your column > from the address bar check the field query string Field=

Note : you can add it as @Actiondeliverydate where this is the field display name but when you try to edit CQWP and set it's value you should add its internal name.

[Update]

Although the above instructions are valid , but unfortunately, Susan told me : It does not display anything.

In fact, The date variable is shown but the forecolor is white , so you will tell me I should remove description class ?

But this also not a solution, if you remove the class it still shows as white so you should set your custom style at the div tag like this <div style="color:black"> or build your custom class

So the final code based on the provided template in chat, should be

<xsl:template name="Actions" match="Row[@Style='Actions']" mode="itemstyle">
    <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>
    <div class="item link-item">
        <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
        <a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
          <xsl:if test="$ItemsHaveStreams = 'True'">
            <xsl:attribute name="onclick">
              <xsl:value-of select="@OnClickForWebRendering"/>
            </xsl:attribute>
          </xsl:if>
          <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
            <xsl:attribute name="onclick">
              <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
            </xsl:attribute>
          </xsl:if>
          <xsl:value-of select="$DisplayTitle"/>
        </a>
        <div style="color:black">
          <xsl:value-of select="ddwrt:FormatDate(string(@Actiondeliverydate), 2057, 3)" />
        </div>
    </div>
</xsl:template>

[Output]

enter image description here

Note:

In the above example : I used @Actiondeliverydate not the internal name, I found out this the field display name and not should be the internal name ,

but when you edit your CQWP web part , you should provide the internal name of 'Action delivery date' field that in this case is Action_x0020_delivery_x0020_date that will be transferred back to Action delivery date

enter image description here

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top