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
    Sep 04, 2014 @ 19:49
    Edward Hertzog
    0

    How to get @nodeType as string

    I'm trying to get an output of a node type, and I'm doing this:

    <xsl:variable name="contentType" select="umbraco.library:GetXmlNodeById(@nodeType)" />

    <xsl:value-of select="$contentType" />

    The only output I get is something like this:

    "No published item exist with id 1217"

    Where @nodeType is 1217.

    What am I doing wrong?

  • Edward Hertzog 12 posts 59 karma points
    Sep 04, 2014 @ 19:57
    Edward Hertzog
    0

    I'm on Umbraco 4.7.2, btw.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Sep 04, 2014 @ 20:04
    Dennis Aaen
    0

    Hi Edward.

    Are you trying to get the XML from a spefic node. If so you can do it like this:

    <xsl:variable name="contentType" select="umbraco.library:GetXmlNodeById(1234)" /> 
    <xsl:value-of select="$contentType/@nodeName" /> 

    Where the 1234 is the id of the page that you want the XML from.

    With this code you will get the node name of the page with the id of 1234 

    You can find the documentation for the umbraco.library:GetXmlNodeById() here http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid

    Hope this helps,

    If I have misunderstood your questions, please write again.

    /Dennis

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

    I'm not trying to get the XML for a specific article. I'm trying to get the content type for it. So I'm trying to generate XML for the nodeType. So, some XML looks like this:

    <TextPage id="1206" parentID="1203" level="2" writerID="0" creatorID="0" nodeType="1205" template="1204" sortOrder="1" createDate="2012-05012T11:54:18" updateDate="2013-02-25T23:32:57" naodeName="About" urlName="about" writerName="admin" creatorName="admin" path="-1,1203,1206" isDoc="">

    So, basically, this document is a TextPage and I want to, I suppose, use the nodeType value in order to determine that. But if I try with your code, or similar code, I get something like this output:

    "No published item exist with id 1205"

     

     

     

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Sep 04, 2014 @ 20:24
    Dennis Aaen
    0

    Hi Edward,

    I think that, you are facing the samme issue as this topic.

    http://our.umbraco.org/forum/developers/xslt/3559--GetXmlNodeById-problem

    Could it be a file permissions issue like radmanmm experiencing here http://our.umbraco.org/forum/developers/xslt/3559--GetXmlNodeById-problem

    Try to check that your file permissions are correct. You can see what permissions should be: http://our.umbraco.org/wiki/reference/files-and-folders/permissions

    You could try to install the uGoLive package http://our.umbraco.org/projects/backoffice-extensions/ugolive to check if yourfile permissions are good.

    Hope this helps,

    /Dennis

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 04, 2014 @ 20:31
    Chriztian Steinmeier
    1

    Hi Edward,

    EDIT: You are calling GetXmlNodeById() - but you're not using an Umbraco node id - the @nodeType attribute is a reference to a Document Type, whereas the function you're calling expects the id of a specific Content node.

    What you want to do can be done by grabbing the first node of that type and then getting its name() - like this:

    <!-- Go up to the absolute root -->
    <xsl:variable name="root" select="$currentPage/ancestor::root" />
    
    <!-- Find the first node with the nodeType we're after -->
    <xsl:variable name="node" select="$root//*[@nodeType = 1217][1]" />
    
    <!-- Print its name -->
    <xsl:value-of select="name($node)" />
    

    If, however, you already have the node in question (like in a for-each or similar), just print the name() - e.g.:

    <!-- Going through children of the current page -->
    <xsl:for-each select="$currentPage/*[@isDoc]">
        <!-- Doing stuff -->
    
        <!-- Print name of current (in loop) node -->
        <xsl:value-of select="name()" />
    </xsl:for-each>
    

    Hope that's what you're after :)

    /Chriztian

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Sep 04, 2014 @ 20:39
    Dennis Aaen
    0

    @Chriztian - Ahh I didn't see that he took the ID of the Document type, and not the ID of the node. Well spotted my friend :-).

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft