Extending the Sitemap/accessing additional data fields
I'm looking to extend the Sitemap feature. I'm looking at the xslt and I see how it is generated. It specifically outputs @id, @nodeName. I'd like to output additional fields, such as the author, tags associated with content, and last update, etc. How/where do I do this? For starters, I'd like to know what fields are available and how I'd go about finding out what those fields are. And, secondly, who do I have to do (in general terms) to access additional data associated with content, such as authors, etc?
To output additional content (i.e. properties) you can just use their alias, e.g.:
<xsl:value-of select="$currentPage/pageTitle" />
Note that properties don't have the @ sign (their childnodes in the XML file, whereas the Umbraco data are attributes).
To inspect the actual XML you can either open the App_Data/Umbraco.config file - OR (shameless plug) - you can install my XMLDump package and do all kinds of scrutinizing :-)
Thanks, the allowed me to progress somewhat. I was able to to figure out some additional properties, such as 'articleAuthor'. But that ends up just giving me an integer. I can see a template elsewhere that this will render the actual name, but it is a macro.
When inserting the umbraco macro into the xslt, it throws an error stating that 'umbraco' is an undeclared prefix. I suppose I can't execute umbraco macros from within the xslt?
I would definitely checkout your package, but I have a feeling that would also just render an integer for the articleAuthor.
Any idea on direction I should persue? I'm using Umbraco 4.7.2
Its important to note that I'm fairly new to xslt and Umbraco, so please excuse the stupid questions.
I think it would help you if you see this documentation, since you are new to Umbraco. If you have a user on umbraco.com, here is a video about what a macro is:
Be aware that this is the old Umbraco TV there is a new version with version 7 viodes, on http://umbraco.tv/ There are some videos that is free, and will explain the basic concepts of Umbraco, and so of them need subscrition. http://umbraco.tv/videos/umbraco-v7/
Thanks, I got a pretty good handle on all of that stuff and see how these things work together (xslt, macros, templates). I'm just sorta stuck on why this macro isn't executing. Or, its executing, but not displaying data. Either way, it looks like I'm going to have to keep hacking at it.
I have an XSLT that it then executes. I have code in there that outputs a CSV of data, which includes content title. That works already. And in addition, I have this in that XSLT, that I wish to use to execute a particular Macro:
I know that particular macro works because it is used in another template (not in an XSLT). (This site was inherited by me, I didn't write this stuff.)
So I'm trying to use a Template to call an XSLT which I'm using to call a Macro within it that I know works elsewhere. I'm kind of at a wall. I understand how this all works together, I'm just not getting any data output. Is there some way to see if the Macro is executing?
Let's just assume for a minute that articleAuthor is a content picker of some sorts, right? The integer you get is the id of the actual Author document (or whatever alias/name they have). All you need to do to get the name of said author, is to render either the @nodeName attribute or if there's an actual fullName property or similar, use that, e.g.:
<xsl:variable name="authorID" select="$currentPage/articleAuthor" />
<xsl:if test="$authorID">
<xsl:variable name="authorNode" select="umbraco.library:GetXmlNodeById($authorID)" />
<!-- Check that other macro for what it actually renders (if there's a fullName property or similar) -->
<xsl:value-of select="$authorNode/@nodeName" />
</xsl:if>
Extending the Sitemap/accessing additional data fields
I'm looking to extend the Sitemap feature. I'm looking at the xslt and I see how it is generated. It specifically outputs @id, @nodeName. I'd like to output additional fields, such as the author, tags associated with content, and last update, etc. How/where do I do this? For starters, I'd like to know what fields are available and how I'd go about finding out what those fields are. And, secondly, who do I have to do (in general terms) to access additional data associated with content, such as authors, etc?
Hi Edward -- welcome to "Our" !
To output additional content (i.e. properties) you can just use their alias, e.g.:
Note that properties don't have the @ sign (their childnodes in the XML file, whereas the Umbraco data are attributes).
To inspect the actual XML you can either open the App_Data/Umbraco.config file - OR (shameless plug) - you can install my XMLDump package and do all kinds of scrutinizing :-)
Hope this helps,
/Chriztian
Thanks, the allowed me to progress somewhat. I was able to to figure out some additional properties, such as 'articleAuthor'. But that ends up just giving me an integer. I can see a template elsewhere that this will render the actual name, but it is a macro.
When inserting the umbraco macro into the xslt, it throws an error stating that 'umbraco' is an undeclared prefix. I suppose I can't execute umbraco macros from within the xslt?
I would definitely checkout your package, but I have a feeling that would also just render an integer for the articleAuthor.
Any idea on direction I should persue? I'm using Umbraco 4.7.2
Its important to note that I'm fairly new to xslt and Umbraco, so please excuse the stupid questions.
So I came across this:
http://our.umbraco.org/wiki/reference/umbracolibrary/rendermacrocontent
But when I implement like this, it renders nothing:
<xsl:value-of select="umbraco.library:RenderMacroContent('<?UMBRACO_MACRO runat="server" macroAlias="ArticleGetAuthorName" ></?UMBRACO_MACRO>', @id)" disable-output-escaping="yes"/>
Hi Edward,
I think it would help you if you see this documentation, since you are new to Umbraco. If you have a user on umbraco.com, here is a video about what a macro is:
http://umbraco.com/help-and-support/video-tutorials/introduction-to-umbraco/sitebuilder-introduction/what-are-macros
Be aware that this is the old Umbraco TV there is a new version with version 7 viodes, on http://umbraco.tv/ There are some videos that is free, and will explain the basic concepts of Umbraco, and so of them need subscrition. http://umbraco.tv/videos/umbraco-v7/
Other good documentation for you might be http://our.umbraco.org/documentation/Using-Umbraco/Creating-Basic-Site/
Here is a written documentation about how a macro is: http://our.umbraco.org/documentation/reference/templating/macros/
Hope this helps, else keep asking questions in the forum. We are friendly people.
/Dennis
Thanks, I got a pretty good handle on all of that stuff and see how these things work together (xslt, macros, templates). I'm just sorta stuck on why this macro isn't executing. Or, its executing, but not displaying data. Either way, it looks like I'm going to have to keep hacking at it.
I'm going to try to debug the macro. I want to see if it is at least getting called. Is this a good place to start with figuring that out?
http://umbraco.com/help-and-support/video-tutorials/introduction-to-umbraco/developer-introduction/debugging.aspx
(I am not getting a yellow screen, just not getting any output)
Hi Edward,
Did you try to add your macro, so you can show the data from you XSLT. This should be in the template and would look like this:
So try to go to the setting section, and click on the template foolder, and find the template that you want the data to be displaying, and add this:
Try to see this: http://our.umbraco.org/wiki/reference/templates/umbracomacro-element
Hope this helps,
/Dennis
I have a Template, which calls my XSLT file. Within that XSLT I want to call a macro. So, basically, it looks like this:
Template named Sitemap contains:
<umbraco:Macro Alias="SiteMap" runat="server"></umbraco:Macro>
I have an XSLT that it then executes. I have code in there that outputs a CSV of data, which includes content title. That works already. And in addition, I have this in that XSLT, that I wish to use to execute a particular Macro:
<xsl:value-of select="umbraco.library:RenderMacroContent('<?UMBRACO_MACRO macroAlias="ArticleGetAuthorName" ></?UMBRACO_MACRO>', @id)" disable-output-escaping="yes"/>
I know that particular macro works because it is used in another template (not in an XSLT). (This site was inherited by me, I didn't write this stuff.)
So I'm trying to use a Template to call an XSLT which I'm using to call a Macro within it that I know works elsewhere. I'm kind of at a wall. I understand how this all works together, I'm just not getting any data output. Is there some way to see if the Macro is executing?
The previous code related to RenderMacroContent is escaped in the actual code.
Hi Edward,
Let's just assume for a minute that articleAuthor is a content picker of some sorts, right? The integer you get is the id of the actual Author document (or whatever alias/name they have). All you need to do to get the name of said author, is to render either the @nodeName attribute or if there's an actual fullName property or similar, use that, e.g.:
/Chriztian
Great, that works perfectly! Thanks for your time!
is working on a reply...