Forum Discussion

mahesh_revanwar's avatar
10 years ago

Forum Topic Page: Message quilt view all link for tags

Hi All,

 

View all link of tags on forum topic page shows view count even if there is an single tag count.

Can we manage this view all link text along with tag count to be generated once the tag count exceeds 4.

 

Is there any configuration change so that we can follow this approach to display view all link after tag count is 4?

 

Thank you.

 

Regards,

Mahesh

  • Hi mahesh_revanwar

     

    I'm not sure this is possible without some customisation of the tag component. What you could do however is remove that counter if it's not important so that you just see the View All link?

     

    There's a text key in Studio under Text Editor > Custom Text:

    general.View_All@count                             = View All ({0,number,integer})

    If you change that by adding a line to the Text Properties box below the search results changing it to 

    general.View_All@count                             = View All

    You should see the link change on the community to drop the number of tags.

     

    To remove the link when there are fewer than 4 tags on a post though will take some development work and possibly a custom component.

  • mahesh_revanwar - Most certainly yes. 

     

    You could use some jQuery on page + some FTL to make this happen. Count the number of tags for the current message using API, this can be done in a custom component on this page.

     

    Now, if the if the tags count is less than 4, execute the jQuery inside this condition. Replace the content in this class with simple "View All". You could also create a new custom component but there would be a lot of effort for that, as Robert mentioned. I hope this helps.

     

           

    <#assign tagCount = restadmin("/restapi/vc/messages/id/[id]/tagging/tags/top/count ").value>

    <#if tagCount?number &lt; 4>
           //your jQuery snippet goes here
    <@liaAddScript>
    ;(function($){
    $('.lia-view-all .lia-link-navigation.view-all-link').html('View All');
    })(LITHIUM.jQuery);
    </@liaAddScript>
    </#if>

     

    • RobertT's avatar
      RobertT
      Boss

      Just adding a few little tweaks to VarunGrazitti 's code to account for multiple messages on the page.

       

      You'll want to use the Freemarker Message Context to grab the message ID of the current message and target that in CSS as well as perform the API call.

       

      There is a CSS class at the root of each message displayed .message-uid-<message id> which you could prepend to the CSS example given so that you target each message individually, this will allow you to drop the new component into the Forum Message quilt in studio.

       

      I'd also recommend wrapping the code as follows with attempt and recover tags to catch any exceptions or errors before pushing any change to production.

       

      <#attempt>
      <#assign tagCount = restadmin("/restapi/vc/messages/id/[id]/tagging/tags/top/count ").value>
      
      <#if tagCount?number &lt; 4>
             //your jQuery snippet goes here
      <@liaAddScript>
      ;(function($){
             $('.lia-view-all .lia-link-navigation.view-all-link').html('View All');
      })(LITHIUM.jQuery);
      </@liaAddScript>
      </#if>
      
      <#recover>
          <!-- what to do if there is an error -->
      </#attempt>

       

      It's worth also noting that this will increase the number of API calls your community uses, depending on the volume of traffic you get which can impact performance, it may be an idea to weigh this up in the long run.