Copied to clipboard

Flag this post as spam?

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

  • Marc-at 2 posts 72 karma points
    Aug 11, 2017 @ 12:46

    Template ID int is always one too low

    Whenever I request a TemplateID of a node it always returns the correct ID, minus one.

    For example: my homepage has ID 1056, but when I try to display it in my view it returns ID 1055..This happens with all document types.

    I currently use this to fix:

    int currentPageId = Model.Content.TemplateId + 1; //dirty hack

    Does anyone have a fix so I don't have to rely on hardcore maths like the hack above? ;)

  • Nik 736 posts 2892 karma points MVP c-trib
    Aug 11, 2017 @ 13:06

    Hi Marc,

    The TemplateID and the NodeID are two different things.

    Looking at the code you are after you want to change your code to Model.Content.Id instead of TemplateId.


Please Sign in or register to post replies

Write your reply to: