Filtering Tags In Blog Post Detail

Posted by Community Admin on 03-Aug-2018 23:03

Filtering Tags In Blog Post Detail

All Replies

Posted by Community Admin on 07-Jul-2011 00:00

We were wanting to show the tags for a given blog post but also to have them be clickable which will then filter out all posts for the given tag. When using the FlatTaxonField control, it only displays the tags and they are not actual links. I know that the TaxonomyControl will allow you to filter either the tags or the categories if you specify the ContentId and the ContentType. Here is how I have my reference to the control in a widget template:

<sf:TaxonomyControl ID="FlatFieldControl" runat="server"  TaxonomyId="cb0f3a19-a211-48a7-88ec-77495c0f5374" FieldName="Tags" ContentID='<%# Eval("Id") %>' ContentType="Telerik.Sitefinity.Blogs.Model.BlogPost" />

When I navigate to a blog post, I get the following error:

Server Error in '/' Application.
 
You are trying to access item that no longer exists. The most probable reason is that it has been deleted by another user.
 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: Telerik.Sitefinity.SitefinityExceptions.ItemNotFoundException: You are trying to access item that no longer exists. The most probable reason is that it has been deleted by another user.
 
Source Error:
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
 
Stack Trace:
 
 
[ItemNotFoundException: You are trying to access item that no longer exists. The most probable reason is that it has been deleted by another user.]
   DynamicModule.ns.Wrapped_OpenAccessContentProvider_653ecc47ab044bdfbb537854b6933b37.GetContent(Guid id) +253
   Telerik.Sitefinity.Modules.GenericContent.ContentManager.GetContent(Guid id) +45
   Telerik.Sitefinity.Web.UI.PublicControls.TaxonomyControl.GetTaxaFromContentItem() +125
   Telerik.Sitefinity.Web.UI.PublicControls.TaxonomyControl.InitializeTaxaList() +173
   Telerik.Sitefinity.Web.UI.PublicControls.TaxonomyControl.InitializeControls(GenericContainer container) +106
   Telerik.Sitefinity.Web.UI.SimpleView.CreateChildControls() +58
   System.Web.UI.Control.EnsureChildControls() +102
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Control.PreRenderRecursiveInternal() +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
 
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

I have even tried using the "OriginalContentId" property as well and I get the same error. Is this a bug, a mis-configuration, or just not an option?

Posted by Community Admin on 08-Jul-2011 00:00

Hello Richard,

There is a bug about this behavior logged in our system and we will try to fix it for Q2 release. The problem is that the taxons are rendered as plain text not as a links.

One of the easiest option would be crating a custom control that uses repeater or RadTreeView ( for HierarchicalTaxons ) and put the control reference in the single template used by your control. You can get the taxons for a given content item using GetValue("Tags") method of DataExtensions

All the best,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 28-Aug-2011 00:00

@Richard - Thanks for the post.  I am having the exact same problem and it was nice to be able to find the answer, even though the answer is that it's a bug.

@Ivan - Can you confirm if this bug was corrected in the Sitefinity 4.2 release?

Posted by Community Admin on 31-Aug-2011 00:00

Hello Liz,

The issue has been fixed in 4.2.

Kind regards,
Victor Velev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Posted by Community Admin on 26-Sep-2011 00:00

Just an update for the thread: I spoke with Telerik form support this morning and due to its complexity, linking tags on a content item level has been upgraded to a Feature.  It has not been fixed in 4.2 nor will it be in 4.2 SP1; we may see the functionality available in 4.3, which is slated for October release at present.

Posted by Community Admin on 29-Sep-2011 00:00

Hello Liz,

Thank you very much for being active and sharing this information in the community. Like I promised during our conversation on Tuesday, I've also synchronized the task with PITS, you can track its proggress and vote for it on this public URL.

All the best,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 29-Sep-2011 00:00

@Boyan - Thanks for the update!

Posted by Community Admin on 09-Jan-2012 00:00

Is this feature available in Sitefinity 4.3 or do you have any code to implement this kind of a functionality. 

Posted by Community Admin on 12-Jan-2012 00:00

Hello,

We are currently working on the feature implementation so it should be out pretty soon in one of the upcoming releases. In the meantime here's a quick workaround:

1. Specify what content tags (only blog post tags in your case) should be displayed by the tag widget. To do this open the Designer of the Tags widget and in the field Content Type enter Telerik.Sitefinity.Blogs.Model.BlogPost.
2. Since in a blog posts widget tags are rendered in span tags, you can use jquery to replace the span with a link for this specific tag from the Tags widget. Take a look at the following sample:

$("#C009_masterBlogPostsFrontend_ctl00_ctl00_Repeater_ctrl0_FlatFieldControl_ctl00_ctl00_taxaList_ctl01_taxonName").replaceWith('<a href="/kjk/-in-Tags/Tags/MyTag">MyTag</a>');
This way when you click on the newly created link, you will filter blog posts, depending on the chosen tag.

Hope you find this information useful.

Regards,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 25-Jul-2012 00:00

Hello

Posted by Community Admin on 25-Jul-2012 00:00

Hello,
Boyan, thank you for the reply. The above provided jQuery solution is static and we need to create the links manually. I have used a different approach to dynamically generate the links for the tags using jQuery. I display the tags on the blog listing page and when you click on them they filter the postings according to the clicked tags.
1. Edit the blog control template to display the tags these tags will be displayed as text. I wrapped my tags inside a div that has a class - tags. I use this as a selector for my jQuery code.
2. Then I used the code below to generate links for each of the tags that are displayed on the page dynamically.

$(document).ready(function()
if($('.tags .sfTagsList li span').length > 0)
    var Link;
    function DetectSpace(s) return s.indexOf(' ');//function to check if space is present
    $('.tags .sfTagsList li').each(function()
        var Text=($(this).find('span').text().trim());
        var space=DetectSpace(Text);
            if(space != -1) // it means the tag has space, so we need to replace the space with "-"
                   Link="<a href=\"/home/about-us/blog/-in-Tags/Tags/"+Text.split(' ').join('-')+"\">"+Text+"</a>";
                    $(this).find('span').replaceWith(Link);
                 
            else
                Link="<a href=\"/home/about-us/blog/-in-Tags/Tags/"+Text+"\">"+Text+"</a>";
                $(this).find('span').replaceWith(Link);
                
        )
    
);

Posted by Community Admin on 12-Dec-2013 00:00

Santen - This jQuery solution for linked tags was exactly what I was looking for - took 2 minutes to install and works like a charm (jQuery 1.8.3 library).  THX 8-)

This thread is closed