Restrict Help Center content using tags Follow

Comments

1 comment

  • Avatar
    Josh Vasile

    I really wish there was a guide to be able to restrict things based off of tags 

    <div id="recentactivity" class="community">
        {{#if help_center.community_enabled}}
          <h4>
            {{t 'community'}}
            {{#link 'community'}}
              {{t 'browse'}}
            {{/link}}
          </h4>
        {{/if}}
        {{recent_activity scope='community'}}
      </div>

     

    CSS addition:

    #recentactivity {
      display: none;
    }

     

    Javascript:

      (function() {
        var isCust;
        // find the tag in the array
        function isCustomer(element, index, array) {
          return (element === 'PLACE-YOUR-TAG-HERE');
        }
        //go through the HelpCenter object and look for org tags
        HelpCenter.user.organizations.forEach(function(x) {
          isCust = x.tags.some(isCustomer);
          return (isCust === true);
        });
        //is this a customer and show them
        if (isCust === true) {
          $('#recentactivity').show();
        }
      }());

    Place the Javascript after the ‘$(document).ready(function() {’ 

    When a tag is placed in 'place your tag here' nothing changes, I have played around with the JS immensely and cannot get anything to work. I know the HTML and Css work fine, I just need JS that works on the recent template update. I can only think that I am looking for the tag run, it was based off this code: 
     
    (function() {
    var isCust;
    // find the tag in the array
    function isCustomer(element, index, array) { return (element === 'paying');
    }
    //go through the HelpCenter object and look for org tags
    HelpCenter.user.organizations.forEach(function(x) {
    isCust = x.tags.some(isCustomer);
    return (isCust === true);
    });
    //is this a customer and show them
    if (isCust === true) {
    $('a[href$="requests/new"]').show();
    $('.my-activities').show();
    $('#user-menu .my-activities').show();
    $('a.submit-a-request').show();
    }
    }());

     

Please sign in to leave a comment.

Powered by Zendesk