Which returned the published product, leading me to believe the query is not querying the contents of categoryList more its value as a string, so is there a way to rewrite either query to read the categories selected inside categoryList rather than it's actual object type.
It does not crash or give me the null error but returns nothing.
If I put it in the second option.
var startNode = Umbraco.Content(1169);
var productSelection = startNode
.Children("boutiqueProduct")
.Where("visible")
.Children()
.Where(x => x.DocumentTypeAlias.Equals("boutiqueProduct") && x.GetPropertyValue<bool>("visible") && x.GetPropertyValue<string>("categoryList").Contains("1127"));
I get the error
Cannot use a lambda expression as an argument to a dynamically
dispatched operation without first casting it to a delegate or
expression tree type.
So at the moment I am hard coding in the categoryId I will want to pass that as a varaible from the id of the page I am on, I guess I will have to convert it to an int along the way ?
Yeah it's the current page, but I pass the ID to an ajax function on another page to render it's contents so I send as query string along with the number of items to render, then a show more button to load more etc.
Querying the Contents of Multinodetreepicker2
I am starting this question again as I seem to have made the last thread tottaly unreadable.
I am trying to query a multinodetreepicker2 element from a page.
I am trying to get all products that contain a given category id from a multinodetreepicker2 object within the product.
I have tried two approaches to no effect, well an effect but normally a yellow screen.
I am hard coding in a categoryNode for testing.
One option was...
categoryList is a multinodetreepicker2 which in this case definatley contains the 1127 node picked. I get the error message.
There is only one product published and it has the 1127 picked.
The other option which kind of works... although not really is this.
This fires but returns no results, so I removed the filter and checked the properties of categoryList it returned.
So on a whim I changed the code to
Which returned the published product, leading me to believe the query is not querying the contents of categoryList more its value as a string, so is there a way to rewrite either query to read the categories selected inside categoryList rather than it's actual object type.
Regards
Doogie
Hi
Try this code:
If I put your line in the first example.
It does not crash or give me the null error but returns nothing.
I get the error
Use strongly typed objects:
Ok if I do...
Nothing returns at all but it doesn't crash.
If I do...
It returns all published products, as expected.
If I do
It doesn't crash but returns nothing.
If I do...
It returns all products.
If I render...
after calling the products it returns...
Which makes me think that the object type is being queried rather than it's contents.
Try this
Cool that works.
So at the moment I am hard coding in the categoryId I will want to pass that as a varaible from the id of the page I am on, I guess I will have to convert it to an int along the way ?
yes, it's int already - just replace it with real id
Cool I am passing it as a query to an ajax function so it arrives as a string. I can parse the string to an int then call it like..
I can't seem to mark your reply as solution :)
And thank you very much for your time.
You are always welcome, happy to help.
Did you mention that category is a current page in Umbraco? If so, you can use currentPage like that:
Umbraco.AssignedContentItem is an easiest way to get the current node.
Yeah it's the current page, but I pass the ID to an ajax function on another page to render it's contents so I send as query string along with the number of items to render, then a show more button to load more etc.
Thanks again.
is working on a reply...