Recent searches


No recent searches

Selectively display attachments in Guide articles

Answered


Posted Sep 29, 2023

In Guide, for some articles I want to link to an article attachment in the body of the article rather than have the attachment shown at the bottom of the article. I know that in style.css I can hide displaying attachments for all articles:

.article-attachments {
  display: none;
  }

What I want is to be able to do the above but selectively per article without having to modify a conditional section in a hbs file with specific article IDs. Is this possible in the CSS?


3

4

4 comments

image avatar

Ifra Saqlain

Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator

@Tom Richards

only with CSS, I don't think it's possible but you can use JS to achieve this instead of checking IDs on hbs file.

if (window.location.href.indexOf("000000000000") > -1) {
     document.querySelector(".article-attachments").style.display = "none";
} else if (window.location.href.indexOf("11111111111111") > -1) {
document.querySelector(".article-attachments-for-body").style.display = "block";
}




Note: for this, you need to add an attachment code block inside the article body as you want to do,
then hide that on all articles but show only on your specific article where you want to show that and you need to hide
that second attachment code, which is already there, hide on your specific article using JS by checking the
article IDs.

 

 

If any confusion feel free to ask :)

Thanks

 

0


Tom Richards

This is something I've been trying to figure out since we migrated our help center to Zendesk two years ago! I think it's ridiculous that attachments only appear at the bottom, especially when wanting to attach/link/display something like a product manual or assembly guide into a table. 

The workaround I found this morning is a bit arduous, but it works! 

  1. Attach the doc to the article and save 
  2. Open preview
  3. Right click on attachment at bottom of article and copy link address
  4. Go back into the article editor and hyperlink whatever text you want with the copied url.
  5. Save and publish.

If anyone out there has a better way, I'm all ears :) 

0


Cameron | Traeger

I've done this as well on occasion, but what spurred my question is my dislike for having both a link in the body and an attachment at the bottom.

By definition an attachment is something at the bottom of an article, so it makes sense why they show there. What we (and a few others) are looking for is a simple way to, in the article body, link to a document stored in the zendesk domain, which is what your workaround does.

An alternative to your step 1 is to attach the document to another article altogether, e.g., an article whose sole purpose is attaching things to. Then the doc won't also appear as an attachment in the article where you've linked to it in the body. The caveat is to make sure the permissions on the article it's attached to are not more restrictive than the one that is linking to it.

0


How come when I put this at the bottom of my style.css the attachment are still appearing in the articles?

 

.article-attachments {
 display: none;
}

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post