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.
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.
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:
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 ;)
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.
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()<= 2">
The number 2 then has to be replaced with $NumberofItemsToDisplay.
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?
Hi Stefan you just need to modfiy your XPath a bit.
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.
You could try this:
<xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(string(@nodeName)), $MaxNoChars, '...')" />
Ron
Slight typo by me there.
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()<= $NumberofItemsToDisplay">
It works just fine if I give the variable any values instead of fetching it from the textstring.
If you display the value of the variable, do you get anything back?
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 ;)
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.
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()<= 2">
The number 2 then has to be replaced with $NumberofItemsToDisplay.
If you understand?
is working on a reply...