Blog Tags Customization
Hello Admin,
I have the following requirement :
- i have 4 Tags in post SEM, SEO, SMO, Google Analytics
- I want to Include a tag cloud ( TagName with No of Count ) on Blogs page. ( Blogs Page displays all the list of Post )
- My BlogPost page is customized (My own User Control ) coz of tht Sitefinities Tags Widget dosent filter the post.It displays
proper TagName with Count
- Please tel me how Should i Customize Tags Widget functionality ? Which methods are used to Display TagName with
Count ?
Please Help me ...
Thanks & Regards
Anu.
Hi Anu,
You have to use TaxonomyManager and its methods to get the taxons and list them in your cloud. Then you have to use GetItemsByTaxon method of ContentDataProvider to get the count of content items associated with a given taxon.
Kind regards,
Ivan Dimitrov
the Telerik team
Hello Ivan,
Thanks for the Reply. Can u give some sample code ?
Hello Anu,
Hello Ivan,
Hi,
i created a custom widget to show a cloud of tags associated with posts of my blog.
The following (simplified) code snippet of my widget .ascx control might not be the best solution, but it works:
<%@ Control Language="C#" %>
<%@ Import Namespace="Telerik.Sitefinity" %>
<%@ Import Namespace="Telerik.Sitefinity.Model" %>
<%@ Import Namespace="Telerik.Sitefinity.Blogs.Model" %>
<%@ Import Namespace="Telerik.Sitefinity.Modules.Blogs" %>
<%@ Import Namespace="Telerik.Sitefinity.Taxonomies" %>
<%@ Import Namespace="Telerik.Sitefinity.Taxonomies.Model" %>
<%@ Import Namespace="Telerik.Sitefinity.Modules.GenericContent" %>
<
script
type
=
"text/C#"
runat
=
"server"
>
public string BlogID get; set;
protected void Page_Load(object sender, EventArgs e)
Guid id;
if (BlogID != "" && Guid.TryParse(BlogID, out id))
Telerik.Sitefinity.Blogs.Model.Blog blog = App.WorkWith().Blogs().Where(b => b.Id == id).Get().SingleOrDefault();
if (blog != null)
TaxonomyManager taxManager = TaxonomyManager.GetManager();
var tags = taxManager.GetTaxonomies<
FlatTaxonomy
>().Where(t => t.Name == "MyTagClassification").SingleOrDefault();
if (tags != null)
foreach (var tag in tags.Taxa)
RadTagCloudItem item = new RadTagCloudItem();
item.Text = tag.Name;
var posts = App.WorkWith().Blog(blog.Id).BlogPosts().Where(ci => ci.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && ci.GetValue<
IList
<Guid>>("MyTagClassification").Contains(tag.Id)).Get().ToList();
item.Weight = posts.Count;
TagCloud1.Items.Add(item);
</
script
>
<
telerik:RadTagCloud
ID
=
"TagCloud1"
runat
=
"server"
></
telerik:RadTagCloud
>
Hello Matthias,
Thank you for your reply and also for providing the code. I was trying to implement the code you have provided below. But, I was thinking how you were associating this widget with each blog post item. Could you please let me know.Sorry, for the question if it is really simple.
Thank you once again.