Copied to clipboard

Flag this post as spam?

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


  • Kate 267 posts 610 karma points
    Sep 24, 2010 @ 13:58
    Kate
    0

    Problem with recursive in macro

    Hi

    Im having problem with my macro. I would like my text field to be recursive.

    What I have done so far:

    In the macro I have created a parameter, alias = contentText , Type = Text.

    In the xslt: <xsl:value-of select="string(/macro/contentText )"/>

    I have a document type called="contenttype", Type="Rich text editor"

    and in my template:

    <umbraco:Macro textToLink="[$tekstTilLinkIReklame]" contentText ="[$contenttype]" infoBillede="[$infoBillede]" linkToUrl="[$linkTilReklame]"  Alias="Newsletter" runat="server"></umbraco:Macro>     

    Im not having any problems with "textToLink", "linkToUrl" and "infoBillede". It is only the richtext editor (contentText ) that I cant get to work with recursiv.


    Can anybody help?

  • Kate 267 posts 610 karma points
    Sep 27, 2010 @ 14:06
    Kate
    0

    Hallo

    Can anybody help?

    I'll try and explain myself again.
    At my homepage I have an advertisement to be displayed on all pages, but the user must be able to edit the text in the advert on the subpages.
    If they have not changed the text on the subpage, the text from the frontpages should be placed there insted.
    There is also an image (picture info = "[$ info image]") and a link in the advert that the user needs to change and it works fine.
    Is there anyone who can explain why it does not work when I want to use a Rich TextEditor?

  • Rich Green 2246 posts 4008 karma points
    Sep 27, 2010 @ 15:08
    Rich Green
    0

    Hi Kate,

    Which version of Umbraco are you using?

    I'm not sure I fully understand your issue but you can use the following in your XSLT to get your values in pre 4.5 Umbraco installs

    You do not need to pass any values in the macro as far as I can tell.

    <xsl:variable name="advertNode" select="$currentPage/ancestor-or-self::node[string(data[@alias='advertText'])!=''] [position()=1] " />
    
    
    <xsl:value-of select="$advertNode/data[@alias='advertText']" />
    
    <xsl:value-of select="$advertNode/data[@alias='advertImage']" />
    
    <xsl:value-of select="$advertNode/data[@alias='contentText']" />

    Basically this says "get me the first node up the tree where the value 'advertText' is not blank.

    Then use this value to get the advertImage / advertText and contentText from the same node.

    Make sense?

    Rich

     

     

  • Kate 267 posts 610 karma points
    Sep 27, 2010 @ 15:27
    Kate
    0

    I´m using Umbraco 4.5 :-)

    And I´m new to umbraco so can you help me rewrite it to 4.5 version

  • Kate 267 posts 610 karma points
    Sep 27, 2010 @ 15:32
    Kate
    0

    What I dont understand is, that it that when I insert text in a text-editor on my frontpage, the text will not be placed on the subpages. But when I insert an Images om my frontpage, the images will be show in the subpages

  • Rich Green 2246 posts 4008 karma points
    Sep 27, 2010 @ 15:32
    Rich Green
    0

    Hi,

    Try this:

    <xsl:variable name="advertNode" select="$currentPage/ancestor-or-self::* [@isDoc][string(advertText)!=''] [position()=1] " />
    
    <xsl:value-of select="$advertNode/advertText" />
    <xsl:value-of select="$advertNode/advertImage" />
    <xsl:value-of select="$advertNode/contentText" />
    
    
    Rich
  • Rich Green 2246 posts 4008 karma points
    Sep 27, 2010 @ 15:37
    Rich Green
    0

    Hi Kate,

    It's very hard to work out what your actual problem is.

    Maybe you could you post a screen shot of your content tree and the paste in XSLT that you are using?

    Rich

  • Kate 267 posts 610 karma points
    Sep 27, 2010 @ 15:49
    Kate
    0

    Sorry, it is not working.

    It is propperly me.

    In the macro you made a paremeter called "advertText", right?

    And when you placed the macro in the template it looks like this

    <umbraco:Macro advertText="[$advertText]" Alias="Editor" runat="server"></umbraco:Macro>

     

     

  • Rich Green 2246 posts 4008 karma points
    Sep 27, 2010 @ 15:53
    Rich Green
    0

    I'm not sure why you need to pass in a parameter.

    The macro will be within a template, and the template knows what page it is being call on via the $currentPage parameter.

    If I understand correctly all pages needs to display an advert, if the current page you are on (a sub page for example)  the admin user has not filled in the details for an advert then you want to display the advert from the level above in the content tree.

    Is that correct?

     

  • Kate 267 posts 610 karma points
    Sep 27, 2010 @ 15:55
    Kate
    0

    Okay, I will try that

    and my xslt:

    <?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"
      exclude-result-prefixes="msxml
    umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes
    Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings
    Exslt.ExsltSets "
    >


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
     <xsl:variable name="advertNode" select="$currentPage/ancestor-or-self::* [@isDoc][string(advertText)!=''] [position()=1] " />

    <xsl:value-of select="$advertNode/advertText" />

      

     
    <!-- start writing XSLT -->

    </xsl:template>

    </xsl:stylesheet>

     

     

  • Kate 267 posts 610 karma points
    Sep 27, 2010 @ 15:57
    Kate
    0

    Yes, you understand my problem correctly :-)

     

  • Rich Green 2246 posts 4008 karma points
    Sep 27, 2010 @ 15:58
    Rich Green
    0

    Hi Kate,

    Could you post an image of the 'Generic Properties' tab for the 'FitnessCenter' node and also the 'Forside' node/

    Rich

  • Kate 267 posts 610 karma points
    Sep 27, 2010 @ 16:06
    Kate
    0

    Fitness

     

    Forside

  • Kate 267 posts 610 karma points
    Sep 27, 2010 @ 16:18
    Kate
    0

    I think it is working. Let me just test it

  • Kate 267 posts 610 karma points
    Sep 27, 2010 @ 16:22
    Kate
    0

    My mistake. Forgot to delete/disabel the parameter in the macro

    Thanks for your help

  • Kate 267 posts 610 karma points
    Sep 28, 2010 @ 15:10
    Kate
    0

    Sorry, it is still not working

    I will try to make a better exampel and then I will return :-)

Please Sign in or register to post replies

Write your reply to:

Draft