What do I have to change to select all the Recipe Items, regardless of which repository they are in? I've tried many things but none have worked. Any ideas? Thanks in advance!
I was about to suggest what Amir posted, but if you are getting an error perhaps it is because you both have a mismatch in what "Model" represents... If not, could you please post the exact error message you're getting?
My theory is that James appears to be using v6+ MVC razor, where "Model" is something of type RenderModel, while Amir appears to be posting pre-MVC code where "Model" is of type DynamicNode.
(Oh, actually James I see you are using "CurrentPage" not Model, which I think is of type DynamicPublishedContent, but the problem still seems to be due to a mismatch in that first line of code.)
How about this instead to fix...?
if (collect == "All")
{
//COLLECT ALL ITEMS SOMEHOW!
rep = CurrentModel.AncestorOrSelf().Descendants("recipeItem").Where("Visible"); // where recipeItem is the doc type alias
}
else
....
Collecting multi-descendant children?
I'm using this to collect Recipe Items inside a particular Repository.
'collect' is the requested Repository name:
Content
- > Homepage
- > Recipe Repository (named rep1)
- > Recipe Item - > Recipe Item
- > Recipe Item
- > Recipe Item
- > Recipe Repository (named rep2)
- > Recipe Item
- > Recipe Item
- > Recipe Repository (named rep3)
- > Recipe Item
- > Recipe Item
- > Recipe Repository (named rep4)
- > Recipe Item
- > Recipe Item
What do I have to change to select all the Recipe Items, regardless of which repository they are in?
I've tried many things but none have worked. Any ideas? Thanks in advance!
Are they all the same document type? If so you can do something like this:
Hi Amir, here is my code:
They are all the same document type.
I collect a querystring (the repository name). 'rep' is a set of items where their repository equals the query.
But I need to collect all items if the query is "All'
I've tried your idea but I get error.
Thanks in advance.
Hi James,
I was about to suggest what Amir posted, but if you are getting an error perhaps it is because you both have a mismatch in what "Model" represents... If not, could you please post the exact error message you're getting?
My theory is that James appears to be using v6+ MVC razor, where "Model" is something of type
RenderModel
, while Amir appears to be posting pre-MVC code where "Model" is of typeDynamicNode
.(Oh, actually James I see you are using "CurrentPage" not Model, which I think is of type DynamicPublishedContent, but the problem still seems to be due to a mismatch in that first line of code.)
How about this instead to fix...?
Good luck!
is working on a reply...