I'm trying to setup an xslt macro that randomly picks a content item under. However, when I try to use contentRandom parameter, nothing is passed to my macro and when I run the page in debug mode the message "Parent doesn't have childeren".
The page selected in the contentRandom does have childeren, and even when I select the website root as parent, the message applies...
Thanks for your reply. The site runs without any errors. The macro is very basic, it only outputs a copy-of the parameter node.
When I run the page with umbShowDebugTrace, a red line appears in the trace notifying that "Error adding random node - parent (1050) doesn't have children!".
Though I don't really understand this "When I remove those macro's, the error occurs. " Are you saying this error only occurs when you remove the other macros?
Do your other macros have parameters?
Maybe try starting again from scratch, new blank template, new XSLT file based on clean template, brand new macro with different parameter name and work from there as it seems like there's something real basic going wrong.
I was already thinking that way. I downloaded the Umbraco sources and trying to set a breakpoint on the contentRandom function. If that doesn't bring a solution I might as wel start over blank.
I ment to say, that when I remove all other macro's, the error still occurs, meaning it's only related to this macro.
Has anyone used the contentRandom function? I can't find many references to this function, not the forum, not google or any blog posts.
I didn't realise there was a contentRandom parameter type! I just thought this was what you were naming your parameter, so sorry for that.
I've never used this but have used other ways to grab random nodes, of which there are plenty of examples on google / here if you can't get this fixed.
Well, you just found a new Umbraco feature today ;) Offcourse I could implement it in another way, but I can't stand it that there is this function but can't get it to work. Perhaps someone of the Umbraco team can shine a light on this?
Obviously the problem has to do with the old xml schema that has been used before, where elements were added as a "node" and not as "Element". I'll ask the team to update this. Solution would be not only to specify the parent element, but also the name of the child elements to select from.
Not only the contentRandom macro parameter is affected, also the contentCurrent macro parameter is affected and will probably not work as expected.
Hi! I used this parameter a lot and since I updated (now in new schema) the contentRandom does not work anymore. How can I specify the name of the child elements?
Parent doesn't have childeren using contentRandom
I'm trying to setup an xslt macro that randomly picks a content item under. However, when I try to use contentRandom parameter, nothing is passed to my macro and when I run the page in debug mode the message "Parent doesn't have childeren".
The page selected in the contentRandom does have childeren, and even when I select the website root as parent, the message applies...
Anyone has clue as to how to sort this out?
I don't know the exact answer to your question, however I would add one step at a time and see exactly where your problem lies as it sounds strange.
Does your template and site run without errors when you do not use this macro?
Can you set up this macro with a clean XSLT file and pass it a single parameter and print this parameter value out?
If you can get to these points then there must be something wrong with your XSLT so I would advise posting your code and content structure here.
Rich
Thanks for your reply. The site runs without any errors. The macro is very basic, it only outputs a copy-of the parameter node.
When I run the page with umbShowDebugTrace, a red line appears in the trace notifying that "Error adding random node - parent (1050) doesn't have children!".
I'm running on Umbraco 4.5.2.
Do any other macros cause this error, can you post your XSLT code here?
There are a few other macro's on the page, but they work as expected. When I remove those macro's, the error occurs. Here's the macro code:
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"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<xsl:param name="randomQuote" select="/macro/randomQuote"/>
<xsl:template match="/">
<pre>
<xsl:copy-of select="$randomQuote"/>
pre>
xsl:template>
xsl:stylesheet>
In my point of view, the error does not occur when the xslt is processed but when the contentRandom macro parameter is accessed:
Can't see any major errors here.
Though I don't really understand this "When I remove those macro's, the error occurs. " Are you saying this error only occurs when you remove the other macros?
Do your other macros have parameters?
Maybe try starting again from scratch, new blank template, new XSLT file based on clean template, brand new macro with different parameter name and work from there as it seems like there's something real basic going wrong.
Rich
I was already thinking that way. I downloaded the Umbraco sources and trying to set a breakpoint on the contentRandom function. If that doesn't bring a solution I might as wel start over blank.
I ment to say, that when I remove all other macro's, the error still occurs, meaning it's only related to this macro.
Has anyone used the contentRandom function? I can't find many references to this function, not the forum, not google or any blog posts.
Hmz, I tried it in another Umbraco website (same 4.5.2 version) I'm running, but the same error occurs...
I didn't realise there was a contentRandom parameter type! I just thought this was what you were naming your parameter, so sorry for that.
I've never used this but have used other ways to grab random nodes, of which there are plenty of examples on google / here if you can't get this fixed.
Rich
Well, you just found a new Umbraco feature today ;) Offcourse I could implement it in another way, but I can't stand it that there is this function but can't get it to work. Perhaps someone of the Umbraco team can shine a light on this?
And I found an Umbraco bug report today :( Having zoomed in at the macro.cs code, there are references to
Obviously the problem has to do with the old xml schema that has been used before, where elements were added as a "node" and not as "Element". I'll ask the team to update this. Solution would be not only to specify the parent element, but also the name of the child elements to select from.
Not only the contentRandom macro parameter is affected, also the contentCurrent macro parameter is affected and will probably not work as expected.
Hi! I used this parameter a lot and since I updated (now in new schema) the contentRandom does not work anymore. How can I specify the name of the child elements?
Hi Profiterole,
If you're changing the source and re-compiling, use Select("*[@isDoc"]) to equal what "node" used to select.
Otherwise, I'd recommend installing uComponents (it's almost a must-install anyway) and try out the RandomNode() extension.
/Chriztian
is working on a reply...