1

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

3
  • @Date should be @InternalNameOfYourDateTimeField
    – Gintas K
    Commented Nov 8, 2016 at 9:29
  • So my @ should be @Action%5Fx0020%5Fdelivery%5Fx0020%5Fdate ???
    – susan
    Commented Nov 8, 2016 at 10:06
  • 1
    It should be @Action_x0020_delivery_x0020_date as in @M.Qassas answer :)
    – Gintas K
    Commented Nov 8, 2016 at 11:06

1 Answer 1

0

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

11
  • It does not display anything. See updated topic. This is what I see inside the CQ, and the result is that only the title is displayed, not the date.
    – susan
    Commented Nov 8, 2016 at 10:42
  • Hi @susan it looks like you tried to modify an item style ?, should you update your question with full modified code for only this item style , also should you tell me from where you h=got this screenshot ? is it when you edit your CQWP ? Commented Nov 8, 2016 at 11:06
  • I made a copy of the style called NOIMAGE and just modified description. The screenshot is from my computer, this is what I see
    – susan
    Commented Nov 8, 2016 at 11:31
  • I know susan it's from your computer :) , I am wondering is it show when you edit your CQWP at field to display section as i have mentioned at this answer sharepoint.stackexchange.com/questions/191972/… Commented Nov 8, 2016 at 11:37
  • yes, it is when I compile the CQWP
    – susan
    Commented Nov 8, 2016 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.