How to access the properties of the parent document for use by children

I am new to Umbraco CMS. Help PLease.

I have a Umbraco website in which I created a DocumentType called "Wizard". The Wizard page allows the user to enter a goal and amount to initiate the fundraising that they take. On the Master page, I have a macro that automatically does the math to generate a percentage that will be used throughout the site. The macro calls the next XSLT

 <xsl:for-each select="$currentPage/ancestor-or-self::*">
  <xsl:variable name="amount" select="* [@alias = 'FundraisingCurrentAmount']"/>
  <xsl:variable name="goal" select="* [@alias = 'FundraisingGoal']"/>
  <xsl:variable name="percentage" select="$amount div $goal * 100"/>
  <xsl:value-of select="$percentage"/>
 </xsl:for-each>

This works, but I assume it is "for everyone", it also returns two NaN results. How can I rewrite this (a) cleaner and (b) so that it works better.

I understand ASP.NET Webforms, so if you can compare with what this will help.

Rate the help.

+3
2

Umbraco . , node, .

.

, , "charityTotaliser", :

<umbraco:macro alias="charityTotaliser" ammount="[$FundraisingCurrentAmount]" goal="[$FundraisingGoal]"runat="server"/>

$, .

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.ExsltMath="urn:Exslt.ExsltMath"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltMath">

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

    <xsl:param name="currentPage"/>

    <!-- Macro parameters -->
    <xsl:variable name="FundraisingCurrentAmount" select="/macro/FundraisingCurrentAmount"/>
    <xsl:variable name="FundraisingGoal" select="/macro/FundraisingGoal"/>

    <xsl:template match="/">

        <xsl:value-of select="$FundraisingCurrentAmount div $FundraisingGoal * 100"/>

    </xsl:template>

</xsl:stylesheet>

, , ( , ):

<umbraco:macro alias="charityTotaliser" ammount="[$FundraisingCurrentAmount], [#FallBackAmmount], 1234" goal="[$FundraisingGoal]"runat="server"/>

+4

XSLT, select. XML, - :

<xsl:for-each select="$currentPage/ancestor-or-self::*[FundraisingGoal>0]">
.
.
.
</xsl:for-each>

, , .

, , , , .

+1

Source: https://habr.com/ru/post/1722049/


All Articles