|
|
Joined: 1/12/2009 Posts: 10
|
Hi, I have a template with a listsummary control. There will be times that the folder the control uses won't contain any content. How can I generate a message on the webpage when there is no content?--something like "No current new articles. Please check back". Thanks for any help! We're using 7.6.6. SP2.
|
|
Joined: 1/16/2008 Posts: 230
|
mr
you can do this a couple of ways.
- XSLT. Are you using an XSLT with your list summary? If so you can add a few lines of code here to display this type of message.
- ASP Literal. In the code behind of your page you could inspect the EKItems property of the ListSummary, if its length is 0 then display the message using the literal.
If you're not using XSLT currently then go with #2.
Carl.
|
|
Joined: 1/12/2009 Posts: 10
|
Thanks, Carl, for the reply! I am actually using an xslt. Can you tell me which xsl element would be used to generate the message? I've been learning xml/xslt as I go, and this one really has me stumped! I'd really appreciate any pointers you can give! Mary
|
|
Joined: 10/2/2006 Posts: 325
|
It would be something similar to this, which checks if the first content is empty, then display message.
<xsl:if test="Collection/Content != ''">There is no content</xsl:if>
Think outside the box. Ektron CMS Smart Form XSLT = Great Design Idea w. Control
|
|
Joined: 1/12/2009 Posts: 10
|
Rui, this seems like the perfect fix! But I'm still having some trouble. I tried using the following:
<xsl:template match="/"> <xsl:for-each select="Collection/Content"> <xsl:choose> <xsl:when test="Collection/Content != ''"> There is no content <xsl:when> <xsl:otherwise> <xsl: value-of... [other fields] </xsl:otherwise> </xsl:choose>
If I have content in the folder it's displaying correctly; however, if there is no content, I'm not seeing the message. Am I applying this correctly?
|
|
Joined: 1/16/2008 Posts: 230
|
Hey Mary,
you have your test inside a for each Content item block, if there are no content blocks then this code will not be executed. Move your test outside the for each loop.
Hope this helps.
Carl
|
|
Joined: 10/2/2006 Posts: 325
|
Here is the working XSLT
<xsl:template match="/"> <xsl:if test="count(Collection/Content) < 1"> There is no content </xsl:if> <xsl:for-each select="Collection/Content"> <li> <xsl:value-of select="Title"></xsl:value-of> </li> </xsl:for-each>
</xsl:template>
Think outside the box. Ektron CMS Smart Form XSLT = Great Design Idea w. Control
|
|
Joined: 1/12/2009 Posts: 10
|
This works beautifully, and is exactly what I needed! Thank you, Carl and Rui, for the explanation and for helping me to understand how to apply it! Mary
|
|
|
|