Sorry for the dufus question, it's late and I'm tired of banging my head on the wall of my ignorance.
I have a site with pages that associated with the geographic locations of structures around the world. I created a 'Structure' document type with dropdown properties for 'continent', 'country', and 'region'. The individual Structure pages are under a content node, 'Structures'. I want to create a list in a sidebar, grouped by those properties, like this:
North America - United States --Alaska --Washington --Oregon - Canada --British Columbia --Alberta - Mexico Europe - England - France - Germany Asia -Japan -China -India
Seems a lot like listing products by category but the examples I found seem to be based on parts of eCommerce packages.
I've tried tweaking other generic examples but they mostly seem to start at current page or at a level, not at a specified node. Thought I was getting close to a start with the node ID of the 'Structures' node:
<ul>
var Node = @Model.NodeById(1110);
@foreach(var page in Node.Children)
{
<li><a href="@level.Url">@level.Name</a></li>
}
</ul>
But it errors out with: ... error CS1061: 'umbraco.interfaces.INode' does not contain a definition for 'Children' and no extension method 'Children' accepting a first argument of type 'umbraco.interfaces.INode' could be found (are you missing a using directive or an assembly reference?)
It's over my fogged head. Can anyone set me on the right track?
Thank you for the reply, Michael. No, I hadn't tried that, I saw one mention of pluralizing but figured since there really was a 'Structures' alias, it might not work. I just tried it and it also returned the same error though, so I'm not sure it fails because of pluralizing, but it doesn't seem to work.
I've seen the cheat sheet but the print was soooo tiny, I'd put it on the back burner until I had time to reformat it without so much margin, mabye spread it across two pages and make a wall-hanger out of it. <g> I'll go get the 3x readers and peruse that cheat sheet again.
I'd also watched a couple of Tim Geyessens Razor tv vids on listing pages and thought I'd get it with .docTypeAlias but I guess I still don't know the syntax well enough to put that together.
Thanks again. If you have any other ideas, I'd be glad to try 'em.
Now I have to figure out how to group them under the property categories for: continent; country; region. I'm off to plagerize but any tips would be much appreciated.
list pages with specific property
Sorry for the dufus question, it's late and I'm tired of banging my head on the wall of my ignorance.
I have a site with pages that associated with the geographic locations of structures around the world. I created a 'Structure' document type with dropdown properties for 'continent', 'country', and 'region'. The individual Structure pages are under a content node, 'Structures'. I want to create a list in a sidebar, grouped by those properties, like this:
North America
- United States
--Alaska
--Washington
--Oregon
- Canada
--British Columbia
--Alberta
- Mexico
Europe
- England
- France
- Germany
Asia
-Japan
-China
-India
Seems a lot like listing products by category but the examples I found seem to be based on parts of eCommerce packages.
I've tried tweaking other generic examples but they mostly seem to start at current page or at a level, not at a specified node. Thought I was getting close to a start with the node ID of the 'Structures' node:
<ul>
var Node = @Model.NodeById(1110);
@foreach(var page in Node.Children)
{
<li><a href="@level.Url">@level.Name</a></li>
}
</ul>
But it errors out with:
... error CS1061: 'umbraco.interfaces.INode' does not contain a definition for 'Children' and no extension method 'Children' accepting a first argument of type 'umbraco.interfaces.INode' could be found (are you missing a using directive or an assembly reference?)
It's over my fogged head. Can anyone set me on the right track?
Thanks.
Hi Matthew,
Have you tried something like this:
To get the children of a specific document type, you can just use the document type alias, pluralized, hence the "Node.Structures" in the foreach.
I don't know if you are aware of it, but there is a very useful "razor dynamic node cheat sheet" pdf file available: http://our.umbraco.org/projects/developer-tools/razor-dynamicnode-cheat-sheet
Hope this helps.
Cheers,
Michael.
Thank you for the reply, Michael. No, I hadn't tried that, I saw one mention of pluralizing but figured since there really was a 'Structures' alias, it might not work. I just tried it and it also returned the same error though, so I'm not sure it fails because of pluralizing, but it doesn't seem to work.
I've seen the cheat sheet but the print was soooo tiny, I'd put it on the back burner until I had time to reformat it without so much margin, mabye spread it across two pages and make a wall-hanger out of it. <g> I'll go get the 3x readers and peruse that cheat sheet again.
I'd also watched a couple of Tim Geyessens Razor tv vids on listing pages and thought I'd get it with .docTypeAlias but I guess I still don't know the syntax well enough to put that together.
Thanks again. If you have any other ideas, I'd be glad to try 'em.
Matthew
Hmmm, I just used the built-in 'Select Children By Document Type' template (don't know why I didn't try that last night):
And it works with the few entries I have so far.
Now I have to figure out how to group them under the property categories for: continent; country; region. I'm off to plagerize but any tips would be much appreciated.
Thanks again,
Matthew
Hi Matthew,
Have you already tried using the.GroupBy("propertyAlias") method?
Cheers,
Michael.
is working on a reply...