I have a placeholder page in Umbraco that renders Biographies. The placeholder page gets a node id from a query string and then renders the data for each bio. The issue is that I have a breadcrumb navigation, so on the placeholder page it looks like this: (biography is the placeholder page)
Our Team : Partners : Biography
What I want it to look like is this:
Our Team : Partners : person's name
so, in my XSLT I getting a nodeId from a query string using:
once I have the node I should be able to access the EmployeeFirstName property on it.
here is my select, which isn't returning anything... <xsl:value-of select="$bioNode/data[@alias='EmployeeFirstName']"/>
so my question is how to i access the properties of node that I am trying to get using my querystring?
I should be able to get the XML for the node using GetXMLNodeById, but how do I find the EmployeeFirstName property within that?
Hope this all makes sense, thanks for the help :)
here is the full XSLT:
<xsl:variable name="minLevel" select="0"/> <!-- get the query string with the biography node id --> <xsl:variable name="bioNodeId" select="umbraco.library:RequestQueryString('Id')"/> <xsl:variable name="bioNode" select="umbraco.library:GetXmlNodeById($bioNodeId)/node"/> <!-- Input the documenttype you want here -->
<xsl:template match="/"> <xsl:if test="$currentPage/@level > $minLevel"> <ul class="breadCrumbNav"> <li> <a href="/">Home</a> </li> <xsl:for-each select="$currentPage/ancestor::* [@level > $minLevel and @nodeName != 'Home']"> <li> : <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName"/> </a> </li> </xsl:for-each> <!-- print currentpage --> <li> : <a href="" class="currentBread"> <!-- when on a biography page show the employee's name --> <!-- string($currentPage/data [@alias='PageHeader']) --> <xsl:choose> <xsl:when test="$currentPage/@nodeName = 'Biography'">
If you are using the old schema, your syntax is correct. However, if you're using the current schema, <xsl:value-of select="$bioNode/EmployeeFirstName"/> should return the correct value.
It depends what the alias of your property is. I am pretty sure that by default, Umbraco will put your first letter in lowercase. As the alias is case-sensitive, it would explain why it didn't return the correct information if you were trying to access EmployeeFirstname. My apologies, I simply pasted the code you'd provided without realising the issue.
trying to get node properties from node ID
I have a placeholder page in Umbraco that renders Biographies. The placeholder page gets a node id from a query string and then renders the data for each bio. The issue is that I have a breadcrumb navigation, so on the placeholder page it looks like this: (biography is the placeholder page)
Our Team : Partners : Biography
What I want it to look like is this:
Our Team : Partners : person's name
so, in my XSLT I getting a nodeId from a query string using:
<xsl:variable name="bioNodeId" select="umbraco.library:RequestQueryString('Id')"/>
with that I am trying to get the node using:
<xsl:variable name="bioNode" select="umbraco.library:GetXmlNodeById($bioNodeId)/node"/>
once I have the node I should be able to access the EmployeeFirstName property on it.
here is my select, which isn't returning anything...
<xsl:value-of select="$bioNode/data[@alias='EmployeeFirstName']"/>
so my question is how to i access the properties of node that I am trying to get using my querystring?
I should be able to get the XML for the node using GetXMLNodeById, but how do I find the EmployeeFirstName property within that?
Hope this all makes sense, thanks for the help :)
here is the full XSLT:
<xsl:variable name="minLevel" select="0"/>
<!-- get the query string with the biography node id -->
<xsl:variable name="bioNodeId" select="umbraco.library:RequestQueryString('Id')"/>
<xsl:variable name="bioNode" select="umbraco.library:GetXmlNodeById($bioNodeId)/node"/>
<!-- Input the documenttype you want here -->
<xsl:template match="/">
<xsl:if test="$currentPage/@level > $minLevel">
<ul class="breadCrumbNav">
<li>
<a href="/">Home</a>
</li>
<xsl:for-each select="$currentPage/ancestor::* [@level > $minLevel and @nodeName != 'Home']">
<li> :
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
<!-- print currentpage -->
<li> :
<a href="" class="currentBread">
<!-- when on a biography page show the employee's name -->
<!-- string($currentPage/data [@alias='PageHeader']) -->
<xsl:choose>
<xsl:when test="$currentPage/@nodeName = 'Biography'">
<xsl:value-of select="$bioNode/data[@alias='EmployeeFirstName']"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currentPage/@nodeName"/>
</xsl:otherwise>
</xsl:choose>
</a>
</li>
</ul>
</xsl:if>
</xsl:template>
I am able to get the nodeName using @nodeName:
<xsl:value-of select="$bioNode/@nodeName"/>
any idea why I can't get the properties?
My property name is EmployeeFirstName so I am doing
<xsl:value-of select="$bioNode/data[@alias='EmployeeFirstName']"/>
I thought this should work, but it's not.
Hi Tim
What does the returned XML from the $bioNode variable look like?
Could you try and write it out like this and tell us what XML you get returned?
<textarea>
<xsl:copy-of select="$bioNode" />
</textarea>
/Jan
Hi Tim,
If you are using the old schema, your syntax is correct.
However, if you're using the current schema, <xsl:value-of select="$bioNode/EmployeeFirstName"/> should return the correct value.
Andrei
@Jan this is what is returned using <textarea>
so I was doing that part right.
Andrei, I was able to get the First and Last names using the new schema like you mentioned.
I did notice that the new schema didn't like using property name with a capital letter first. EmployeeFirstName didn't return anything.
employeeFirstName returned what I wanted....strange.
but thank you guys very much for your help, I appreciate it.
Hi Tim,
It depends what the alias of your property is. I am pretty sure that by default, Umbraco will put your first letter in lowercase. As the alias is case-sensitive, it would explain why it didn't return the correct information if you were trying to access EmployeeFirstname. My apologies, I simply pasted the code you'd provided without realising the issue.
I'm glad it helped, though.
Hi Tim
Just want to add to Andrei is posting above.
The alias elements in the XML first letter are always lowecased and the document type elements first letters are always uppercased.
But it's always a good idea to write out the XML to see what you're up against :)
/Jan
Andrei, no worries, I was able to figure it out pretty quickly once I got the correct syntax from you.
Jan, your trick out spitting out all the XML is a useful one and I will definetly use it again.
thanks again for all your help guys, this place is great!
is working on a reply...