Now, I want to get
Product-1.1.1, Product-1.1.2, Product-1.2.1, Product-1.2.2, Product-2.1.1, Product-2.1.2, Product-2.2.1, Product-2.2.2 in single query. How can I get that?
Of course you need to replace the doctype aliases with the correct ones.
Also when having a lot of categories the .Descendants call can be a performance hit. So make sure that you cache this information.
Document Type of Home node and Product category node is different. Then which document type I have to define as DocTypeAliasOfHomeNode ? Of home node or Product Category node ?
var homeNode = Model.AncestorOrSelf("DocTypeAliasOfHomeNode");
This code will traverse up the tree from your current page and will find the ancestor of the type homepage. If it is executed on the homepage it will return the homepage as well. You should replace "DocTypeAliasOfHomeNode" with the actual doctype alias of your home node.
Then this piece of code will get all your pages under the "Home" node of the specified document type, no matter on what level they are in the tree.
Again I got one issue. If I run the page of Product category, I am getting exact output that I want. But now I want that When I run the page of Home node, I want product list.
When line
var homeNode = Model.AncestorOrSelf("DocTypeAliasOfHomeNode");
get executed it is giving null. Not getting how to get it. Help me.
Get subchild of multiple node using single query
Hello,
I Want to display product category and its product. I have displayed it.
My node structure is like :
Now, I want to get
Product-1.1.1, Product-1.1.2, Product-1.2.1, Product-1.2.2, Product-2.1.1, Product-2.1.2, Product-2.2.1, Product-2.2.2 in single query. How can I get that?
Thank You.
Hi Dipa,
You can do something like this :
Of course you need to replace the doctype aliases with the correct ones. Also when having a lot of categories the .Descendants call can be a performance hit. So make sure that you cache this information.
Dave
Hi Dave,
Its worked for me. Thanks.
Hi Dave,
Your help is really helpful to me. But now, in project, node structure get changed. Now it is like below :
Now how can I get only products?
Thanks,
Dipa
You can actually you use the same code.
Dave
Thanks Dave for replying soon.
But my doubt is :
Document Type of Home node and Product category node is different. Then which document type I have to define as DocTypeAliasOfHomeNode ? Of home node or Product Category node ?
Thanks,
Dipa
Hi Dipa,
Maybe i should explain the code a bit.
This code will traverse up the tree from your current page and will find the ancestor of the type homepage. If it is executed on the homepage it will return the homepage as well. You should replace "DocTypeAliasOfHomeNode" with the actual doctype alias of your home node.
Then this piece of code will get all your pages under the "Home" node of the specified document type, no matter on what level they are in the tree.
You should replace "DocTypeOfCategory" to the actual doctype of your product.
Dave
Thanks Dave.
I got it.
Hi Dave,
Again I got one issue. If I run the page of Product category, I am getting exact output that I want. But now I want that When I run the page of Home node, I want product list.
When line
get executed it is giving null. Not getting how to get it. Help me.
Thanks,
Dipa
Did you replace "DocTypeAliasOfHomeNode" with the doctype alias of your home documenttype ?
Or maybe you can try this instead :
Dave
Hi Dave
I replaced it but not working.
Dipa
Hi Dave
I want product list in Home page. For that my project structure is like below. Just go through it.
I want product in home page.
Thanks
Dipa
So your product categories are on the same level as the homepage ?
Dave
You can probably change your code to this :
Dave
is working on a reply...