Trying to build a tag cloud in Umbraco 6 using Razor macro. The cloud should show all tags in a specific blog instance.
So then I discovered the Tag.GetTags method. This seems to accept a node id, and returns the tags belonging to that node. It also accepts a string called group, but not sure what this does. So is there an Umbraco business logic function to get all the tags for blog posts under a blog node? Or do I have to do it manually, getting the posts, looping through, building a list of tags and all that?
"Group" maps to the group you set on the Tags datatype (see Developer -> Datatypes -> Tags). This is useful if you want to use Tags for two different functions on your website (like a Blog and a News section) and have them use a different set of tags.
As best practice I always set the 'group', even if it's the only one I'm using at the moment - just to make life easier later on. If you already have a bunch of tags mapped, maybe you can try passing an empty string for the group parameter - or setting it and seeing if that works right away or not.
I've used Tags.GetTags("blogposts") to generate tag clouds in the past, so sounds like you're on the right track :)
Hello. So if I understand you correctly, you're saying I should create separate datatypes for the tags I'm going to use in each blog. Put a group of "blog1" and "blog2" on the new tag datatypes, and tell my blog post document types to use the corresponding tag datatypes. Then when I want to generate a tag cloud for one of the blogs I just need to pass in the correct group name? Or is there a way to set the tag datatype group name when I link it into a document type?
Yeah, exactly as you said is the way I would recommend doing it. Then you can do something like:
var blogTags = Tag.GetTags("blog1").OrderByDescending(t => t.NodeCount);
You'll just need to pass in the name you're using for the tag group - there's not really a way to link it up based on the doctype. Maybe you could create a property on each Blog doctype called "Tag Group" to pull this from.
businesslogic.Tags.Tag.GetTags
Trying to build a tag cloud in Umbraco 6 using Razor macro. The cloud should show all tags in a specific blog instance.
So then I discovered the Tag.GetTags method. This seems to accept a node id, and returns the tags belonging to that node. It also accepts a string called group, but not sure what this does. So is there an Umbraco business logic function to get all the tags for blog posts under a blog node? Or do I have to do it manually, getting the posts, looping through, building a list of tags and all that?
Hi,
"Group" maps to the group you set on the Tags datatype (see Developer -> Datatypes -> Tags). This is useful if you want to use Tags for two different functions on your website (like a Blog and a News section) and have them use a different set of tags.
As best practice I always set the 'group', even if it's the only one I'm using at the moment - just to make life easier later on. If you already have a bunch of tags mapped, maybe you can try passing an empty string for the group parameter - or setting it and seeing if that works right away or not.
I've used Tags.GetTags("blogposts") to generate tag clouds in the past, so sounds like you're on the right track :)
Hope this helps,
Tom
Hello. So if I understand you correctly, you're saying I should create separate datatypes for the tags I'm going to use in each blog. Put a group of "blog1" and "blog2" on the new tag datatypes, and tell my blog post document types to use the corresponding tag datatypes. Then when I want to generate a tag cloud for one of the blogs I just need to pass in the correct group name? Or is there a way to set the tag datatype group name when I link it into a document type?
Yeah, exactly as you said is the way I would recommend doing it. Then you can do something like:
You'll just need to pass in the name you're using for the tag group - there's not really a way to link it up based on the doctype. Maybe you could create a property on each Blog doctype called "Tag Group" to pull this from.
-Tom
Hi,
In backend is there any possibility to move the tags... I mean change the position of tag once it is entered?,
Thanks for you support, in advance :)
Regards
Tri Mandir
Hi Tri,
No, it doesn't look like the default Tags datatype supports sorting. There might be some other packages you could use, though.
Might be worth logging as a feature request on the issue tracker too: http://issues.umbraco.org/
-Tom
Hello Tom
Thanks for responding.
-Trimp
is working on a reply...