I have a razor script that is creating links back to the parent page unless it doesn't have the property "CourseCatalogInternal" in which it is to just output the node name. Problem with my else statments though they are displaying the link then the following else statement printed out. What is wrong with my syntax?
Part of the problem is that the document type alias of "CourseCatalogInternal" in the first @if is never recognized even though it is the exact alias for that DocType. What's up?
Thanks overlooked that. Now I need the first @if statement to work. Do I not understant .HasProperty ? Shouldn't I be able to put the doctype page alias in as .HasProperty ("CourseCatalogHome") ?
Well, I got it working. It's not gracefull though. Aparently there is not a way to target the doc type alias so I targeted a property of the parent page of the top most node of this section I am working on. Surely there is a way to target the @Model DocTypeAlias ?
Should return what you require - another really good way of traversing is in the razor walkthrough, if you want to return to a parent, @Model.Up().NiceUrl will give you a return to the parent in any child page, think that was in about razor walkthrough 7, in an old blog post. (NiceUrl if you are using or Url if not)
Link back to the parent node
I have a razor script that is creating links back to the parent page unless it doesn't have the property "CourseCatalogInternal" in which it is to just output the node name. Problem with my else statments though they are displaying the link then the following else statement printed out. What is wrong with my syntax?
Sorry,
The code posted incorrectly and it would not let me edit or delete it. So here is my code again.
Part of the problem is that the document type alias of "CourseCatalogInternal" in the first @if is never recognized even though it is the exact alias for that DocType. What's up?
Think you have a stray semi-colon?
Looks like its taking out of code
G
Thanks overlooked that. Now I need the first @if statement to work. Do I not understant .HasProperty ? Shouldn't I be able to put the doctype page alias in as .HasProperty ("CourseCatalogHome") ?
Well, I got it working. It's not gracefull though. Aparently there is not a way to target the doc type alias so I targeted a property of the parent page of the top most node of this section I am working on. Surely there is a way to target the @Model DocTypeAlias ?
Hmm
Think you might get away with @if (page (!="CourseCatalogInternal")) , it is something similar if not exactly this.
could be page without the second brackets
G
I am now trying to check for the doc type alias of "CourseCatalogHome" and then assign it it's node name with a link.
I've tried
@if (Model("CourseCatalogHome")) {
@if (Model.CourseCatalogHome) {
This worked! Thanks for your suggestions!
@if (Model.Where("nodeTypeAlias == \"CourseCatalogHome\"")) {
Hi Steve
Hope you have it sorted by now, but just for completeness in case anyone is looking for the same answer, this worked for me ;
@foreach (var item in parent.Children.Where("NodeTypeAlias != \"YourDocTypeAlias\"")) != giving the not
so should give an alternative.
As Im writing just seen your reply so,
@if (Model.NodeTypeAlias == "CourseCatalogHome") {}
Should return what you require - another really good way of traversing is in the razor walkthrough, if you want to return to a parent, @Model.Up().NiceUrl will give you a return to the parent in any child page, think that was in about razor walkthrough 7, in an old blog post. (NiceUrl if you are using or Url if not)
Hope it helps
G
is working on a reply...