Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Edward Hertzog 12 posts 59 karma points
    Aug 27, 2014 @ 17:03
    Edward Hertzog
    0

    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?

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 27, 2014 @ 23:19
    Chriztian Steinmeier
    0

    Hi Edward -- welcome to "Our" !

    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 :-)

    Hope this helps,

    /Chriztian

  • Edward Hertzog 12 posts 59 karma points
    Aug 28, 2014 @ 20:04
    Edward Hertzog
    0

    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.

  • Edward Hertzog 12 posts 59 karma points
    Aug 28, 2014 @ 21:01
    Edward Hertzog
    0

    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('&lt;?UMBRACO_MACRO runat=&quot;server&quot; macroAlias=&quot;ArticleGetAuthorName&quot; &gt;&lt;/?UMBRACO_MACRO&gt;', @id)" disable-output-escaping="yes"/>
     
      

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 28, 2014 @ 21:18
    Dennis Aaen
    1

    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

  • Edward Hertzog 12 posts 59 karma points
    Aug 28, 2014 @ 21:24
    Edward Hertzog
    0

    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.

  • Edward Hertzog 12 posts 59 karma points
    Aug 28, 2014 @ 21:47
    Edward Hertzog
    0

    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)

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 28, 2014 @ 21:49
    Dennis Aaen
    0

    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:

    <umbraco:Macro Alias="ArticleGetAuthorName" runat="server"></umbraco:Macro>

    Try to see this: http://our.umbraco.org/wiki/reference/templates/umbracomacro-element

    Hope this helps,

    /Dennis

  • Edward Hertzog 12 posts 59 karma points
    Aug 28, 2014 @ 21:57
    Edward Hertzog
    0

    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?

  • Edward Hertzog 12 posts 59 karma points
    Aug 28, 2014 @ 21:59
    Edward Hertzog
    0

    The previous code related to RenderMacroContent is escaped in the actual code.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 28, 2014 @ 22:07
    Chriztian Steinmeier
    0

    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.:

    <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>
    

    /Chriztian

  • Edward Hertzog 12 posts 59 karma points
    Aug 28, 2014 @ 22:33
    Edward Hertzog
    0

    Great, that works perfectly! Thanks for your time!

Please Sign in or register to post replies

Write your reply to:

Draft