You'll notice that there are some pieces of regular text like (Contact Informaiton, suite, Phone: ect.) included. But I don't want this section to show up at all on the Level 1 pages that use Template "A"
What I would like to do is have a statement in Template “A” that says: If your Parent (or parent’s parent, ect.) is using template “B” then show this section of code. If there is no parent using the template “B” then show nothing.
Is that possible? To wrap this section of code in an if statement?
My Goal here is to allow my department's admin update his contact information on his main page (which uses Template "B") and then be able to show that information on all of his sub pages. I would also like not to create an additional template just to suit this need.
First of all: I'm pretty sure you're also using two different document types for the documents in in your tree, since that is the only possible way to have documents with different icons, these document types
I'd probably use a little xslt-file and a macro to solve this problem. But you could do it from a masterpage's codebehind as well if you needed to. Here's my take on a solution using a xslt macro (this code is assuming you're on a recent version of Umbraco using the new xml schema)
<xsl:template match="/">
<!--
The code below will only output something if there's a page in the path
above the currentpage that is based on DoctypeB
-->
<xsl:apply-templates select="$currentPage/ancestor-or-self::DoctypeB" />
</xsl:template>
<xsl:template match="DoctypeB">
<h2>Contact information</h2>
<strong><xsl:value-of select="./DepartmentTitle" /></strong><br />
<!-- More html/property values here -->
</xsl:template>
You'd need to create a xslt file for the above code, and a macro to render it and then insert the macro in your template using an <umbraco:Macro /> tag.
Specific "If Statement" needed to display content only on Child Pages
Hello Everyone,
I believe I could use an "If Statement" to solve my issue below. Take a look at the image below to get an idea of my content tree.
Inside of Template "A" I placed the following code:
You'll notice that there are some pieces of regular text like (Contact Informaiton, suite, Phone: ect.) included.
But I don't want this section to show up at all on the Level 1 pages that use Template "A"
What I would like to do is have a statement in Template “A” that says:
If your Parent (or parent’s parent, ect.) is using template “B” then show
this section of code. If there is no parent using the template “B” then show
nothing.
Is that possible? To wrap this section of code in an if statement?
My Goal here is to allow my department's admin update his contact information on his main page (which uses Template "B") and then be able to show that information on all of his sub pages. I would also like not to create an additional template just to suit this need.
Hi FarmFreshCode,
First of all: I'm pretty sure you're also using two different document types for the documents in in your tree, since that is the only possible way to have documents with different icons, these document types
I'd probably use a little xslt-file and a macro to solve this problem. But you could do it from a masterpage's codebehind as well if you needed to. Here's my take on a solution using a xslt macro (this code is assuming you're on a recent version of Umbraco using the new xml schema)
<xsl:template match="/"> <!-- The code below will only output something if there's a page in the path above the currentpage that is based on DoctypeB --> <xsl:apply-templates select="$currentPage/ancestor-or-self::DoctypeB" /> </xsl:template> <xsl:template match="DoctypeB"> <h2>Contact information</h2> <strong><xsl:value-of select="./DepartmentTitle" /></strong><br /> <!-- More html/property values here --> </xsl:template>
You'd need to create a xslt file for the above code, and a macro to render it and then insert the macro in your template using an <umbraco:Macro /> tag.
Regards
Jesper Hauge
Nice. Thanks Jesper! I put that example in place and it seems to be working out just great. Thats a much cleaner solution than "if statements".
is working on a reply...