[SOLVED] Unique ID for a NodeType


(Bernhard Witz) #1

Is there an easy way to add an unique ID automatically in my template? I’m new to Neos and maybe I overlooked something in the documentation. It’s sufficient if the ID is unique within the page.

Here a simplified version of my NodeType template to show what I’m trying to do ({XXX} should be an unique ID):

{namespace neos=Neos\Neos\ViewHelpers}
< style >

    #{XXX} {

    <f:if condition="{backgroundImageDesktop}">
        <f:then>

        background-image: url({neos.media:uri.image(image: node.properties.backgroundImageDesktop)});

        </f:then>
    <f:else>

      background-image: url(http://placehold.it/1680x640);

    </f:else>

    </f:if>
    }

</style>


<div id="{XXX}" class="image--container stage">
</div>

(Soren Malling) #2

Most likely {node.identifier} could do the trick for you


(Bernhard Witz) #3

Thank you! This variable did the job. Here how it looks now if someone else is interested.

Template:

<div id="id-{node.identifier}" class="image--container stage">
</div>

Rendered HTML:

<div id="id-23404ebf-e950-41b3-ad05-9933fed77aca" class="image--container stage">
</div>