Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stefan 117 posts 215 karma points
    Jul 17, 2009 @ 13:11
    Stefan
    0

    Truncate @nodeName in newslist

    Hi.

    I'm trying to make a newslist, where I've encountered some small problems.

    I want to truncate the name of the news items listed, but I can't get it to show the "real" nodeName. The title="{@nodeName}" gives me the correct values, but data ['@nodeName'] somehow gives me my metaKeywords.

    It's the following syntax marked with bold that are giving me trouble.

            <li>
                <a title="{@nodeName}" href="{umbraco.library:NiceUrl(@id)}">
                    <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(data ['@nodeName']), $MaxNoChars, '...')" />
                </a>
            </li>

    If I for example want to put the bodyText values in, it all works fine.

    What am I doing wrong?

  • Warren Buckley 2089 posts 4578 karma points MVP ∞ admin hq c-trib
    Jul 17, 2009 @ 13:14
    Warren Buckley
    0

    Hi Stefan you just need to modfiy your XPath a bit.

    <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(@nodeName'), $MaxNoChars, '...')" />

    Remove the square brackets and the word data. As the nodename is an attribute of the <node> node where <data> node is where the custom properties for the node are stored.

  • Ron Brouwer 273 posts 768 karma points
    Jul 17, 2009 @ 13:15
    Ron Brouwer
    1

    You could try this:

    <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(string(@nodeName)), $MaxNoChars, '...')" />

    Ron

  • Warren Buckley 2089 posts 4578 karma points MVP ∞ admin hq c-trib
    Jul 17, 2009 @ 13:16
    Warren Buckley
    2

    Slight typo by me there.

    <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(@nodeName), $MaxNoChars, '...')" />
  • Stefan 117 posts 215 karma points
    Jul 17, 2009 @ 13:31
    Stefan
    0

    Thanks for your quick replies! It works like a charm now!

    Maybe you also can help me with the following:

    I'm trying to limit the number of items listed, which is working fine when I write the number directly in my code. When I try to use a variable to fetch the number, it doesn't work.

    The document-type I want the number from is "Nyhedsgruppe", and the alias for the textstring is "nyhedsgruppeItems".

    Again it must have something to do with my path. I have tried several syntaxes, and this is where I'm stuck right now:

    <xsl:variable name="NumberofItemsToDisplay" select="string($currentPage/data [@alias='nyhedsgruppeItems'])" />

     

    This is how I'm making use of the variable.

    <xsl:if test="position()&lt;= $NumberofItemsToDisplay">

    It works just fine if I give the variable any values instead of fetching it from the textstring.

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jul 17, 2009 @ 13:53
    Peter Dijksterhuis
    0

    If you display the value of the variable, do you get anything back?

    ! <xsl:value-of select="$NumberofItemsToDisplay"/> !
  • Stefan 117 posts 215 karma points
    Jul 17, 2009 @ 14:02
    Stefan
    0

    No, thats the problem, I don't know how to get a hold of that string.

    The newslist is showing regardless of which page I'm on, so I need the correct path to the "nyhedsgruppeItems" (whis is a part of doc-type "Nyhedsgruppe".

    I'm fairly new to Umbraco, so that might be the real problem ;)

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jul 17, 2009 @ 14:14
    Peter Dijksterhuis
    0

    Ah ok. You're calling the macro from within the template that belongs to the doc-type "Nuhedsgruppe" right? You could pass that value as parameter to the macro. You don't need to worry in your macro where to get that value from then.

  • Stefan 117 posts 215 karma points
    Jul 17, 2009 @ 14:35
    Stefan
    0

    I've just tried what you suggested, which also gives me the correct value of what I've defined. Also, thanks for pointing this solution out - didn't know of that :)

    But, I want the users of the site to be able to define the number of newsitems to list from the contentpage. Thats why I've added a textfield with the alias "nyhedsgruppeItems" to the "Nyhedsgruppe" doc-type.

    I just need to put in the value from that field into this:

        <xsl:if test="position()&lt;= 2">

    The number 2 then has to be replaced with $NumberofItemsToDisplay.

    If you understand?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies