NomadTraveler
NomadTraveler

Reputation: 1084

Sitecore query filter issue

I am new to Sitecore and have come across a situation for which I haven't been able to find any documentation.

I have two blogs, Blog A and Blog B. Each Blog has various Categories.

Now, I am trying to create a template, where the user can select a Blog and then select Categories. For Bog Selection, I have used a Droptree and for Categories Selection, I have used a Multilist. I can fetch all the Categories using the following query :

query:../../..//*[@@templatename= 'Category']

But, this fetches all the categories belonging to both the Blogs. What I want to do is - when the user has selected the Blog in the DropTree, I want to populate the Multilist only with the categories belonging to that particular blog.

Any ideas? Thanks!

Upvotes: 0

Views: 710

Answers (1)

Kam Figy
Kam Figy

Reputation: 326

I don't think Sitecore Query supports what you're after (basically using a field value from another item as a variable in a query, if I understand correctly).

There's a guide to the whole of query on SDN: http://sdn.sitecore.net/reference/using%20sitecore%20query/sitecore%20query%20syntax.aspx

I think I'd look at creating a custom field type that inherited from multilist and overriding the logic that pulls items based on the data source - then you can filter it programmatically however you want. There are various blog posts available on that subject, such as http://gettingtoknowsitecore.blogspot.com/2010/03/custom-fields-part-1.html

You could also consider putting categories as subitems under each blog to drastically simplify the whole thing - then you could simply use a relative query or an ancestor-or-self query without anything custom.

Upvotes: 1

Related Questions