recursive property with dollar sign not returning value
Hi
I have a macro that displays an advert based on a script stored in a string document property.
When I pass the property value to the Advert Macro I want it to get the value recursivley so that if no advert is specified it gets it from the documents above. I am finding that the value is an empty string.
thanks for replying. I'm using umbraco v
4.5.2 (Assembly version: 1.0.3891.20719).
I have looked really closely, both the above line are on the same template and the field values are identical.
If I supply an Advert script for the actual document you are on you get the advert, but if you delete the string the following method shows the parent Advert:
<umbraco:Itemfield="leftFooterAdScript"
whilst the following doesn't:
<umbraco:MacroadScript="[$leftFooterAdScript]"
The one thing I wonder is if my document contains the field value but it is an emtpy string whether one method considers that a value to return and the other decides to recurse up when it sees the empty string.
Just another idea for possible cause of troubles: have you tried making the macro parameter name completely small-lettered? I am mentioning this because just a few days ago I had similar problems of parameter value not being passed, and I ended up discovering that my macro parameter, which alias definition contained capital letters, was in fact populated at run time completely small lettered. So, if you can't sort out the CData issue (which IMHO is probably taken care of correctly), maybe you can try renaming your macro parameter alias to "adscript" and then use it in your xslt like this:
thanks for the reply. Have just tried that and unfortunately hasn't fixed it.
The thing is that the macro will display a value fine provided the page you are on has a field value that is not an empty string has. It just won't return a value from a page above when I empty the advert script for the current page.
the only problem with that is I have several Adverts in my template e.g. leftFooter, midFooter, rightFooter, banner etc, each supplying values to an advert macro.
How do I pass something into the macro to use a specific set of values to render each unique advert.
I was trying to avoid having specific macros for each advert placeholder - seems very clunky. Any suggestions?
Right of course, I lost that aspect along the way...
Well, I have never tried it and I am also no XSLT expert, but what about passing the property name (leftFooter, midFooter etc.) - not its value - as string parameter to the macro, and then use that property value in your recursion query? That way you would keep your advert macro generic and you just need to pass the appropriate advert position as parameter to your macro.
Tried to test again with a textMulti field that all pages inherit. Gave the homepage a value and displayed it down on a sub page and initially it displays fine, but if you update the subpage page without entering anything into the new field, you end up with an empty CData value in Umbraco config. Then the $ param no longer recurses up to the homepage value.
Is there no-one from the core Umbraco team who can shed light on this as it seems like quite fundamental functionality. The ability to recurse is a really important part of Umbraco's flexibility and $ params seemed a really neat bit of functionality..
recursive property with dollar sign not returning value
Hi
I have a macro that displays an advert based on a script stored in a string document property.
When I pass the property value to the Advert Macro I want it to get the value recursivley so that if no advert is specified it gets it from the documents above. I am finding that the value is an empty string.
If I test the property value using a recursive field value it shows the value correctly:
I expected them to return the same values. How can I get a recursive value to pass into my macro?
Hi Simon
The above looks correct to me. Are you sure that there is not a typo or a missing value?
What version of Umbraco are you using?
/Jan
Hi Jan,
thanks for replying. I'm using umbraco v 4.5.2 (Assembly version: 1.0.3891.20719).
I have looked really closely, both the above line are on the same template and the field values are identical.
If I supply an Advert script for the actual document you are on you get the advert, but if you delete the string the following method shows the parent Advert:
whilst the following doesn't:
The one thing I wonder is if my document contains the field value but it is an emtpy string whether one method considers that a value to return and the other decides to recurse up when it sees the empty string.
thanks, Simon
should metion that in my Ad Macro I have the following to render the advert script:
Any ideas anyone?
Seems that "$" and "umbraco:Item field" interpret an empty string differently - how can I get resolve this?
Got it, its because the field is a multi line text, even when its empty it leaves <![CDATA[]]>
Is there a way to remove empty CData tags when the textbox multiple field value is empty?
Hi Simon,
Just another idea for possible cause of troubles: have you tried making the macro parameter name completely small-lettered? I am mentioning this because just a few days ago I had similar problems of parameter value not being passed, and I ended up discovering that my macro parameter, which alias definition contained capital letters, was in fact populated at run time completely small lettered. So, if you can't sort out the CData issue (which IMHO is probably taken care of correctly), maybe you can try renaming your macro parameter alias to "adscript" and then use it in your xslt like this:
and see what happens?
Cheers,
Michael.
Hi Michael,
thanks for the reply. Have just tried that and unfortunately hasn't fixed it.
The thing is that the macro will display a value fine provided the page you are on has a field value that is not an empty string has. It just won't return a value from a page above when I empty the advert script for the current page.
Hi Simon,
Too bad :-S
I guess you can alway get the value recursively right in the xslt script then, if nothing else works.
Cheers,
Michael.
Hi Michael,
the only problem with that is I have several Adverts in my template e.g. leftFooter, midFooter, rightFooter, banner etc, each supplying values to an advert macro.
How do I pass something into the macro to use a specific set of values to render each unique advert.
I was trying to avoid having specific macros for each advert placeholder - seems very clunky. Any suggestions?
cheers,
Simon
Right of course, I lost that aspect along the way...
Well, I have never tried it and I am also no XSLT expert, but what about passing the property name (leftFooter, midFooter etc.) - not its value - as string parameter to the macro, and then use that property value in your recursion query? That way you would keep your advert macro generic and you just need to pass the appropriate advert position as parameter to your macro.
Cheers,
Michael.
Have been trying that but I haven't got the syntax right:
Would rather the $ params would work :(
Tried to test again with a textMulti field that all pages inherit. Gave the homepage a value and displayed it down on a sub page and initially it displays fine, but if you update the subpage page without entering anything into the new field, you end up with an empty CData value in Umbraco config. Then the $ param no longer recurses up to the homepage value.
Is there no-one from the core Umbraco team who can shed light on this as it seems like quite fundamental functionality. The ability to recurse is a really important part of Umbraco's flexibility and $ params seemed a really neat bit of functionality..
Hope its something I'm doing wrong.
Given up with textMultiple, seems to work with textstring.
This bug was fixed in 4.7.
I had a fix for this for 4.6.1 if you need it (umbraco.dll) however it might just be easier to upgrade to 4.7
Rich
Thanks for the reply.
Have yet to do an ugrade process. Will be upgrading from v4.5.2 - Is it easy???
is working on a reply...