Forum Discussion

Akenefick's avatar
Akenefick
Genius
2 years ago

How to get Content Filter lists

Is there a way to get the content filter lists with Freemarker or API? I'm guessing I should be able to use community.settings.name but not sure. I want the login list from Content Filters in Admin. Thanks

 

 

 

  • That would certainly be an option yes, then you could use the snippet above to extract the list into a machine readable format and have it there to use in FreeMarker, just don't forget to update it if you update the list. You could also use a custom content field for the same purpose, just note that both, custom settings and custom content fields are length limited (I think 10000 characters by default, but don't quote me on that), so if your list is particularly long you might have to ask for a higher character limit for your custom setting.

  • I'm not aware of such a setting, I don't think these Admin settings are exposed through freemarker. You could get them with a bit of javascript magic though, but of course you need to be logged in as someone with access to the community Admin, otherwise it won't (or shouldn't) work:

     

    var host = 'https://<your-community-host>';
    var list = 'smut'; // <filter-list-name>
    var html = (await (await fetch(`${host}/t5/bizapps/page.adminmanagecontentfilters.editfilter:editfilterwords?filter-name=${list}&t:ac=tab/community%3Aadmin%3Amoderatortools%3Acontent-filters&t:cp=admin/contributions/page`, {
      "headers": {
        "accept": "application/json, text/javascript, */*; q=0.01",
        // only needed on staging environments!
        "authorization": "Basic <base64-encoded-htaccess-credentials",
        "cache-control": "no-cache",
        "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
        "lithium-ajax-request": "true",
        "pragma": "no-cache",
        "x-requested-with": "XMLHttpRequest"
      },
      "body": "",
      "method": "POST",
      "mode": "cors",
      "credentials": "include"
    })).json()).response?.components?.[0]?.content || '';
    
    var results = [...(new DOMParser()).parseFromString(html, 'text/html').querySelectorAll('td.filteredWordColumn')].map((el) => el.innerText);
    
    console.log(results);

     

     

    This will return an array of filtered words in that filter-list.

    • Thanks. That's great, but like you said this would need to work for regular users. We have SSO and a customization (I'm guessing by Khoros?) that allows name changes on the community. The out of box name change is not present for SSO accounts. The customization does not take into account the content filter list for login names. I was hoping I could grab it easily, but maybe I can have support add a field in settings list editor and keep a list there.