Copied to clipboard

Flag this post as spam?

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


  • Brian McNally 16 posts 104 karma points
    Jul 21, 2021 @ 19:34
    Brian McNally
    0

    Show portions of template based on page Guid ID

    Any help appreciated. I need to have a template show content based on the current page Guid. Is this possible? I know it's not best practice but I'm just trying to quickly re-create some older version templates on the cloud. This isn't a long term solution and is on a very custom landing page template where the content isn't really created in the CMS but hard coded.

    Something like

    @if (currentPage.Guid == "sag-sdfg-sdfg"){ [show this content] }

    Also this does not have to be using GUIDs if there is another solution. It could be using the urls or some other mechanism. Just need to render different content based on which page it's coming from

    @if(landingPage 1 ){ show this content } @if (landingPage2) { show this content }

  • Brendan Rice 538 posts 1102 karma points
    Jul 21, 2021 @ 20:52
    Brendan Rice
    0

    Try currentPage.Id or Model.Id

  • Brian McNally 16 posts 104 karma points
    Jul 21, 2021 @ 20:56
    Brian McNally
    0

    this is on cloud, so wouldn't ID be bad for moving between local and the cloud sites?

  • Brendan Rice 538 posts 1102 karma points
    Jul 21, 2021 @ 21:04
    Brendan Rice
    0

    It is a bad approach to reply on Id especially between environments.

    What are you actually trying to do and there may be a better way.

    Model.ContentType.Alias might be a better appraoch

  • Brian McNally 16 posts 104 karma points
    Jul 21, 2021 @ 21:20
    Brian McNally
    0

    So same templates being used. Same doctype too. We have LandingPageA & LandingPageB. just need to be able to have different content on each (not using grid or content entered into CMS) IF that makes sense. I know it's not ideal but this is coming from a v7 on-prem site where I just had 2 different hard coded templates. We are now in the cloud and using a different theming mechanism/structure. So I need to find a way to display different content based on which node/page it is. These templates were a 1 time build and not being used again so I don't have interest in rebuilding everything out to be editable in the CMS if that makes sense. I can create partial view templates with the body content from the previous two templates but just need a way to differentiate which page is using he template.

  • Brendan Rice 538 posts 1102 karma points
    Jul 21, 2021 @ 21:23
    Brendan Rice
    0

    Can you not use the Model.Url (or Model.Url()) to figure it out?

Please Sign in or register to post replies

Write your reply to:

Draft