|
|
Rank: Newbie
Joined: 1/24/2008 Posts: 12
|
Is there a way to determine the name of a property from its source node? I have a list of properties, but I need the property name to describe the values. Thanks.
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,078 Location: KY, USA
|
In the Document Type you set the "alias" of the various properties. The alias is the internal name of the property and it is how you reference it in xslt. Let's suppose you had a DocType for your music collection and had created text fields for the Artist and Album Name (aliases of 'artist' and 'album'). In your xslt, you would use something like: Code: <xsl:value-of select="$currentPage/data [@alias='artist']" /> <xsl:value-of select="$currentPage/data [@alias='album']" />
Is this what you mean? cheers, doug.
MVP 2007/2008 - Official Umbraco Trainer for North America - Percipient Studios
|
|
Rank: Newbie
Joined: 1/24/2008 Posts: 12
|
Hi Drobar, Thanks for taking the time to help.
Actually, I understand how to access the property by alias, but I need to determine the name of the property from the alias.
The previous developer created a series of properties with aliases like "Item1", "Item2", "Item3", but I need to loop through them and the property name is the appropriate title to display as the label for the property value. So, I have access to the node, its data elements and the alias names, but I cannot figure out how to determine the actual property name from the alias. Does that make sense?
I even tried querying the document type node id to figure out the property names that way, but I get the entire website, so I guess that isn't a possibility.
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,078 Location: KY, USA
|
If the data you're looking for doesn't actually exist in the node's content then I can't think of any (convenient) way to do what you're looking for. So, how do you get the content of a node to see what's in there? Simple. Just make a quick xslt macro that has this code if you put the macro on the page you actually want to look at: Code: <xsl:copy-of select="$currentPage" />
Or this code if you want to get the contents of another node and you know what the node's id is. You can pass the desired nodeid in to the macro, but I've just hard-coded it in this example. Code: <xsl:copy-of select="umbraco.library:GetXmlNodeById('1200')" />
When you run this, your browser isn't going to know how to show the XML output properly. So view the source of the page to see the full and complete results. You'll see your "Item1", "Item2", "Item3" aliases. Do you also see the information you want to get out? If so, post the node content and tell us what you want to get out... we'll do our best to whip up the xslt to do it. For further reading, check out http://forum.umbraco.org/yaf_postst2008_Small-new-package--XmlOutput.aspxcheers, doug.
MVP 2007/2008 - Official Umbraco Trainer for North America - Percipient Studios
|
|
Rank: Newbie
Joined: 1/24/2008 Posts: 12
|
Hi Drobar, So far, I've been up to speed on the advice you've given, but the link posted provided some interesting details. The Umbraco Extension that was posted returns the NAME of the property rather than the ALIAS. This leads me to believe that there must be a method to retrieve node data that has the Property ALIAS and the NAME and the Value. With both NAME AND ALIAS, I would have the information I need to properly display the data.
copy-of GetXMLByID() or $currentPage only returns the Property ALIAS and Value, but not the Property NAME. I'm wondering if anyone knows of a function that I can use in an XSLT to retrieve all three values.
Thanks.
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,078 Location: KY, USA
|
Sorry if I've appeared to be a bit slow in understanding exactly what you were looking for. I've got it now. :) What you're trying to do is get some information that is NOT in the node's xml representation. Therefore, you can't get what you want with any of the built-in xslt routines. Instead, you'll have to query umbraco to get the name associated with the alias for the document you want. This is what Tim did. Your choices to do this are: 1. Use Tim's package 2. Write your own usercontrol to do exactly what you want 3. Write an xslt extension If you have a usercontrol, it will be called by a macro and must return the output you want. If you have an xslt extension, you can take the output and further massage it within an xslt macro. That makes the xslt extension somewhat more flexible, but the choice really depends on your needs. cheers, doug.
MVP 2007/2008 - Official Umbraco Trainer for North America - Percipient Studios
|
|
|
Guest |