Copied to clipboard

Flag this post as spam?

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


  • Simon Osborne 108 posts 150 karma points
    Mar 17, 2011 @ 22:34
    Simon Osborne
    0

    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.

    <umbraco:Macro adScript="[$leftFooterAdScript]" Alias="Advert" runat="server"></umbraco:Macro>

     

    If I test the property value using a recursive field value it shows the value correctly:

    <umbraco:Item field="leftFooterAdScript" recursive="true" runat="server"></umbraco:Item>

     

    I expected them to return the same values. How can I get a recursive value to pass into my macro?

     

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 17, 2011 @ 22:48
    Jan Skovgaard
    0

    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

  • Simon Osborne 108 posts 150 karma points
    Mar 18, 2011 @ 09:09
    Simon Osborne
    0

    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:

    <umbraco:Item field="leftFooterAdScript"

    whilst the following doesn't:

    <umbraco:Macro adScript="[$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.

     

    thanks, Simon

  • Simon Osborne 108 posts 150 karma points
    Mar 18, 2011 @ 09:12
    Simon Osborne
    0

    should metion that in my Ad Macro I have the following to render the advert script:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <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:template match="/">
        <xsl:value-of select="/macro/adScript" />
    ...
  • Simon Osborne 108 posts 150 karma points
    Mar 22, 2011 @ 10:25
    Simon Osborne
    0

    Any ideas anyone?

  • Simon Osborne 108 posts 150 karma points
    Mar 22, 2011 @ 10:29
    Simon Osborne
    0

    Seems that "$" and "umbraco:Item field" interpret an empty string differently - how can I get resolve this?

  • Simon Osborne 108 posts 150 karma points
    Mar 22, 2011 @ 14:11
    Simon Osborne
    0

    Got it, its because the field is a multi line text, even when its empty it leaves <![CDATA[]]>

  • Simon Osborne 108 posts 150 karma points
    Mar 22, 2011 @ 14:33
    Simon Osborne
    0

    Is there a way to remove empty CData tags when the textbox multiple field value is empty?

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Mar 22, 2011 @ 15:22
    Michael Latouche
    0

    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:

    <xsl:value-of select="/macro/adscript" />

    and see what happens?

    Cheers,

    Michael.

  • Simon Osborne 108 posts 150 karma points
    Mar 22, 2011 @ 15:35
    Simon Osborne
    0

    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.

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Mar 22, 2011 @ 16:07
    Michael Latouche
    0

    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.

  • Simon Osborne 108 posts 150 karma points
    Mar 22, 2011 @ 16:11
    Simon Osborne
    0

    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

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Mar 22, 2011 @ 16:23
    Michael Latouche
    0

    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.

  • Simon Osborne 108 posts 150 karma points
    Mar 22, 2011 @ 16:38
    Simon Osborne
    0

    Have been trying that but I haven't got the syntax right:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary" xmlns:CommerceLibrary="urn:CommerceLibrary" xmlns:parser.html2xml2="urn:parser.html2xml2"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary CommerceLibrary parser.html2xml2 ">



    <xsl:output method="xml" omit-xml-declaration="yes"/>
      <xsl:param name="currentPage"/>
      <xsl:variable name="advertscriptname" select="string(/macro/adscript)"/>
        
    <xsl:template match="/">

      <xsl:variable name="advertNode" select="$currentPage/ancestor-or-self::* [@isDoc][$advertscriptname !=''] [position()=1] " />
      <xsl:value-of select="$advertNode/$advertscriptname" disable-output-escaping="yes" />

    </xsl:template>

    </xsl:stylesheet>

     

  • Simon Osborne 108 posts 150 karma points
    Mar 26, 2011 @ 16:20
    Simon Osborne
    0

    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.

  • Simon Osborne 108 posts 150 karma points
    Mar 27, 2011 @ 16:44
    Simon Osborne
    0

    Given up with textMultiple, seems to work with textstring.

  • Rich Green 2246 posts 4008 karma points
    Mar 27, 2011 @ 17:15
    Rich Green
    1

    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

  • Simon Osborne 108 posts 150 karma points
    Mar 27, 2011 @ 21:30
    Simon Osborne
    0

    Thanks for the reply.

    Have yet to do an ugrade process. Will be upgrading from v4.5.2 - Is it easy???

Please Sign in or register to post replies

Write your reply to:

Draft