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
}
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.
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 }
Try currentPage.Id or Model.Id
this is on cloud, so wouldn't ID be bad for moving between local and the cloud sites?
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
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.
Can you not use the Model.Url (or Model.Url()) to figure it out?
is working on a reply...