I have a document type that is used in different areas of the website.
On this document type is a tag group named 'default'.
I have seen other forum posts where someone wants to list pages that contain a given tag. But what I want to do is pull a sub-list of tags based on their location under a given node.
So for example, I might have the following content tree structure:
-site root
--sub 1
---sub 1.1
---sub 1.2
--sub 2
--- sub 2.1
--- sub 2.2
--- sub 2.3
Note that sub 1.x and sub 2.x use the same document type. I want to generate and display a list of tags on sub 2 which are in use on pages under sub 2 only.
I see that there is an xslt extension for tag type:
getTagsFromNode(int nodeid)
But what I want is something like getTagsUnderNode (int nodeid).
I realize that another solution would be to just have separate document types where a different tag group could be defined. But I'm trying to avoid that.
Is there some XSLT magic to do it using a predicate?
Actually, I realize, that I do not need to use the extension methods for tags.
I can just pull a list of nodes where the tag field is not null, like this:
But, I quickly realize, that this is not going to work. I need to somehow create a distinct list, and take into account that some nodes will have 1 tag, and others will have more than one, separated by commas....
...although I think that I have heard that putting this type of C# code (the call to gecko:DistinctValues($thetags), defind in the link above) in your templates is bad practice? Or maybe it's only when such C# code queries the database (which it is not doing here).
Yes it's not a good idea (there are/were some serious memory issues with it). Fortunately you can just move the code into an App_Code Extension and have it work the same.
I've never worked with the "tags" datatype so can't really offer any advice - I don't know how its stuff is stored in the XML tree...
filtering tag list by location
I have a document type that is used in different areas of the website. On this document type is a tag group named 'default'.
I have seen other forum posts where someone wants to list pages that contain a given tag. But what I want to do is pull a sub-list of tags based on their location under a given node.
So for example, I might have the following content tree structure:
-site root --sub 1 ---sub 1.1 ---sub 1.2 --sub 2 --- sub 2.1 --- sub 2.2 --- sub 2.3
Note that sub 1.x and sub 2.x use the same document type. I want to generate and display a list of tags on sub 2 which are in use on pages under sub 2 only.
I currently get my tag list like this:
I see that there is an xslt extension for tag type: getTagsFromNode(int nodeid)
But what I want is something like getTagsUnderNode (int nodeid).
I realize that another solution would be to just have separate document types where a different tag group could be defined. But I'm trying to avoid that.
Is there some XSLT magic to do it using a predicate?
Actually, I realize, that I do not need to use the extension methods for tags. I can just pull a list of nodes where the tag field is not null, like this:
and then loop through them...
But, I quickly realize, that this is not going to work. I need to somehow create a distinct list, and take into account that some nodes will have 1 tag, and others will have more than one, separated by commas....
...and thanks to this post, I figured it out:
...although I think that I have heard that putting this type of C# code (the call to gecko:DistinctValues($thetags), defind in the link above) in your templates is bad practice? Or maybe it's only when such C# code queries the database (which it is not doing here).
Hi Jacob,
Yes it's not a good idea (there are/were some serious memory issues with it). Fortunately you can just move the code into an App_Code Extension and have it work the same.
I've never worked with the "tags" datatype so can't really offer any advice - I don't know how its stuff is stored in the XML tree...
/Chriztian
is working on a reply...