Recent searches


No recent searches

Remove attachments from appearing in all help center articles



Posted Feb 20, 2024

Hello team, 

Context: a help center that uses multiple languages.

Current situation: when adding an attachment to a help center article, the attachment appears in all articles. 

For example, a help center exists in English and French. When adding an attachment in an English article, the attachment will also appear in the French article (and vice versa). 

I was wondering if this could be changed because it is not very handy to have attachments appearing automatically in all languages. Instead, could it be possible that the attachments only appear in the article they are attached to? 

Let me know if you need more information. 

Thanks in advance. 

Victoria


0

1

1 comment

image avatar

Jakub

Zendesk Customer Care

Hello Victoria Maurin

I can see that the attachments added to an article are available for all its translations, meaning, if you add an attachment to an English version of the article, it will also appear under the Spanish version of that article. 

Unfortunately, at this time there is no possibility to separate them between languages.

The only workaround I can think of would require manual approach to hide those attachments on specific languages. 

To achieve this, you can write a JavaScript code snippet that checks the current document's language and the article ID in the URL. If the conditions match (the language is pt-BR and the article ID is 21847166575508 - my example), the code will hide the element with the class article-attachments.
// Function to extract the article ID from the URL
function getArticleIdFromUrl(url) {
  const regex = /articles\/(\d+)-[a-z]{2,3}/; // Adjusted regex to match the provided URL format
  const match = url.match(regex);
  return match ? match[1] : null;
}

// Function to hide the element with class 'article-attachments'
function hideArticleAttachments() {
  const articleId = getArticleIdFromUrl(window.location.href);
  const targetArticleId = '21847166575508';
  const pageLang = document.documentElement.lang;

  if (pageLang === 'pt-BR' && articleId === targetArticleId) {
    const attachments = document.querySelector('.article-attachments');
    if (attachments) {
      attachments.style.display = 'none';
    }
  }
}
You would need to adjust this code if you want to hide multiple attachments in a specific locale, and then create another for different locales and articles. 

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post