this is just to get a list of checkbox items. Firstly, I couldn't find the ID of the item, I've got that from the SQL database table cmsDataType. Anyway, it won't display anything. What am I doing wrong?
If I can get the data as a list I can sort it from there, I just can't get anything at the moment.
GetXmlNodeById expects a string so when you hardcode the id like in your sample above you need to write umbraco.library:GetXmlNodeById('1096') - Then you shold be able to see some output :)
Another tip - instead of using <xsl:value-of select="$content" /> to see what you get returned it would make your life much more easy to do this
This will give you the XML returned and you can copy the result from the textarea into an xml file to get a better overview of what you're dealing with.
First off: You shouldn't have to look in the database for IDs - click the node in Umbraco and check the Properties tab - also, hovering any node in the Content Tree will typically (browser-dependent) reveal a JavaScript function in the statusbar, containing the ID.
Second: GetXmlNodeById() returns Content nodes - are you trying to get the DataType node? (I may just be confused by your mention of "cmsDataType").
Third: Using <xsl:value-of /> will return a string of the concatenated text() nodes descending from the node you select - if the selected node hasn't got any custom properties defined and none of its child-nodes have properties defined, the result will be an empty string. So you may actually have the right node (?) - use Jan's suggestion to get the XML (or go Pro and install the XMLDump package :-)
@Jan: I'd be very surprised if the method signature of GetXmlNodeById() expects a string and not an Int32 - but luckily I don't need to know, because I know XSLT will provide the correct type, as long as the value supplied can be converted :-)
@Chriztian: Well...in the extensions dropdown in Umbraco's XSLT editor it says the following: umbraco.library:GetXmlNodeById(String id)...So I suppose that means it expects a string, which is indeed odd...but what do I know...I'm just a chef! ;-)
Ahh, got you. That gives me a string of the values to select from. How do I get the ones which have been checked in the back end? is that another request?
also if I use that to get values from dropdowns\checkbox lists,when would you use the GetXmlNodeById()?
In order to get those checked in the backend you need to just fetch the value from the property.
Since I don't know anything about your setup this explanation is general..
To get the selected value from the backend using XSLT you would create a macro and insert it in the template, which the document is using.
The content of the XSLT file could look something like this...(<xsl:template> and the other "standard" stuff has been omitted for this simple example).
@Jan: I stand corrected :-) (Very inconsistent - especially since it was probably put in there right about the same time NiceUrl() was added... nevermind)
GetXmlNodeById not showing anything
Hi All,
I am trying to use this xsl:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:CWS.Twitter="urn:CWS.Twitter"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets CWS.Twitter ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="content" select="umbraco.library:GetXmlNodeById(1096)" />
<xsl:value-of select="content" />
</xsl:template>
</xsl:stylesheet>
this is just to get a list of checkbox items. Firstly, I couldn't find the ID of the item, I've got that from the SQL database table cmsDataType. Anyway, it won't display anything. What am I doing wrong?
If I can get the data as a list I can sort it from there, I just can't get anything at the moment.
Help
Hi Mat
GetXmlNodeById expects a string so when you hardcode the id like in your sample above you need to write umbraco.library:GetXmlNodeById('1096') - Then you shold be able to see some output :)
Another tip - instead of using <xsl:value-of select="$content" /> to see what you get returned it would make your life much more easy to do this
<textarea>
<xsl:copy-of select="$content" />
</textarea>
This will give you the XML returned and you can copy the result from the textarea into an xml file to get a better overview of what you're dealing with.
Hope this helps.
/Jan
Hi Jan,
That makes sense. I'm now getting
No published item exist with id 1096
I've tried other ID's and the text one and still nothing. Am so close but yet so far :)
Cheers
Mat
Is the ID you're trying to receive by any chance a media id? In that case you need to have a look at GetMedia instead :)
/Jan
No, its created in the data types section in developer of the back end.
Hi Mat,
First off: You shouldn't have to look in the database for IDs - click the node in Umbraco and check the Properties tab - also, hovering any node in the Content Tree will typically (browser-dependent) reveal a JavaScript function in the statusbar, containing the ID.
Second: GetXmlNodeById() returns Content nodes - are you trying to get the DataType node? (I may just be confused by your mention of "cmsDataType").
Third: Using <xsl:value-of /> will return a string of the concatenated text() nodes descending from the node you select - if the selected node hasn't got any custom properties defined and none of its child-nodes have properties defined, the result will be an empty string. So you may actually have the right node (?) - use Jan's suggestion to get the XML (or go Pro and install the XMLDump package :-)
@Jan: I'd be very surprised if the method signature of GetXmlNodeById() expects a string and not an Int32 - but luckily I don't need to know, because I know XSLT will provide the correct type, as long as the value supplied can be converted :-)
/Chriztian
Argh...forget my previous post..
Just reread your post...
You're trying to get data from a datatype with the id 1596?
If you need to get data from a dropdown datatype you perhaps need to use GetPreValues('1596') instead.
Does this return anything?
/Jan
@Chriztian: Well...in the extensions dropdown in Umbraco's XSLT editor it says the following: umbraco.library:GetXmlNodeById(String id)...So I suppose that means it expects a string, which is indeed odd...but what do I know...I'm just a chef! ;-)
/Jan
Ahh, got you. That gives me a string of the values to select from. How do I get the ones which have been checked in the back end? is that another request?
also if I use that to get values from dropdowns\checkbox lists,when would you use the GetXmlNodeById()?
Hi Mat
In order to get those checked in the backend you need to just fetch the value from the property.
Since I don't know anything about your setup this explanation is general..
To get the selected value from the backend using XSLT you would create a macro and insert it in the template, which the document is using.
The content of the XSLT file could look something like this...(<xsl:template> and the other "standard" stuff has been omitted for this simple example).
<xsl:value-of select="$currentPage/yourpropertyname" />
Hope this makes sense :)
/Jan
@Jan: I stand corrected :-) (Very inconsistent - especially since it was probably put in there right about the same time NiceUrl() was added... nevermind)
is working on a reply...