Recent searches
No recent searches
Icon before article title
Answered
Posted Feb 26, 2020
Hi everyone!
I always seem to have a lot of questions. Maybe one day I can actually help someone else out!
We would like to add an icon before certain articles that show that an article is about a new feature or is updated. We can do that with text or adding an emoji, but I would like to use some of our branding instead. This would require a way to add a jpg, png, etc to the front of an article title. How can I do this?
See the icon on Twitter below. Thanks!
0
30
30 comments
Ifra Saqlain
Hey Lisa :),
First, you need to add that image in the assets on the HC. See twitter.jpg image.
If you want to add icon or image (jpg, png, etc) to the front of the article title on article_page.hbs then add that icon or image to the front of article title code.
See line no. 38 :
See, the twitter image is added to the front of an article title.
If you need to add the different-different icons or images for every article title then follow this article. https://support.zendesk.com/hc/en-us/community/posts/360038804574-Sort-Articles-by-Label
OR
If you want to add icons or images to the front of the article list then same thing you can do on other pages e.g (section page, category page, etc.) add the image or icon to the front of {{title}}.
category page, see line no. 42
Section page, see line no. 46
If any query let me know.
Thank You
Team
0
Lisa Sedlak
Thanks!
I wanted something for different articles. So I figured it out using this code and another. This is what I have in category_page:
{{#if section.articles}}
<ul class="article-list">
{{#each section.articles}}
<li class="article-list-item {{#if promoted}} article-promoted{{/if}}">
{{#if promoted}}
<span data-title="{{t 'promoted'}}" class="icon-star"></span>
{{/if}}
{{#is id 360038868131}} <img src="{{asset 'updatebutton50x21.png'}} "/>{{/is}}
For others, that number is a link to the article number.
I then added it to the section_page as well.
I then get this:
So now my next question is, how do I get that image to show up BEHIND the text. I am trying some CSS stuff to see what I can do, but any help is appreciated.
0
Ifra Saqlain
Hey Lisa,
You need to add code after the article title. Please see the given image line no. 45 to 50.
Result:
Twitter image is added behind the text.
This is on section template but same thing would be done on category page for showing the image behind the article text.
Add article IDs with images after {{title}} tag.
You can do this by CSS code using ::after or ::before.
If any issue let me know :)
Thank You
Team
0
Lisa Sedlak
That did it!
Thank you so much!
0
Ifra Saqlain
:D Enjoy
0
Lisa Sedlak
I have hit a new snag. I have some articles that link directly to an outside site - like Terms of Use links to the external page so I don't have to change the text all the time. That is interfering with the code above. Not sure how to fix. Here is the code and then what it looks like. It doubles the title.
<a href="{{url}}" class="article-list-link">
{{title}}
{{#is id 360038484732}} <img src="{{asset 'NewButton.png'}} "/>{{/is}}
{{#is id 360038868131}} <img src="{{asset 'updatebutton.png'}} "/>{{/is}} </a>
<a href="{{url}}" class="article-list-link">
<a {{#is id 360039251672}} href="https://voice.com/legal/terms-of-use/" class="article-link" {{/is}}
href="{{url}}" class="article-link">{{title}}</a>
0
Ifra Saqlain
Hey Lisa,
You need to add this code in your script file after the document ready function:
You just need to update IDs of articles here:
Here add your external links:
No need to add code for outside links on hbs template. Just paste that given code on your script file and update your article IDs and external links.
If any issue let me know :)
Thank You
Team
0
Lisa Sedlak
I am sending you virtual Girl Scout cookies! Thank you so much!
0
Ifra Saqlain
:)
0
Lucy Long
What steps can I follow if I want to add an image before an article title that is just a normal article (not promoted or featured)?
Thanks!
0
Nicole Saunders
Hi Lucy -
The solutions above should work whether the articles have been featured/promoted or not. I don't see anything in the solution that indicates you have to feature or promote the article in order to use this code to insert an icon.
0
Ifra Saqlain
Hi Lucy,
Nicole is right.
You just need to
upload image in the assets in hc
add image before {{title}} on article page
no need to check ID, promoted,featured and all
save and publish
It's done
If any other query feel free to ask :)
Thank You
0
Lucy Long
Thank you! So if I want to choose which articles I want to display the icon, then I will need to supply the article ID?
0
Ifra Saqlain
Yes :)
Go through this article
https://support.zendesk.com/hc/en-us/community/posts/360042268273-How-to-add-icons-symbols-to-article-titles?page=1#community_comment_360010851494
0
Danny Koss
Is it possible to add icons to the search_results.hbs template? Specifically, I'm looking to add the lock fas icon to search results that are set to "internal."
0
Ifra Saqlain
Hi Danny,
Go to your search_results.hbs file.
Find for 'results-list-item-link'
Add the given code before the '{{title}}'
0
Danny Koss
Hi Ifra, thanks very much for the response.
I receive an error when using is_external - I'm guessing this may be because we are using a v1.0 API guide theme. Do you know if that might be the issue? If so, is there a way to reference internal/external articles in the search_results template using v1.0 API?
0
Ifra Saqlain
Danny Koss, I tried in V1 theme and it's not possible from my side.
0
Ashley Boose
Hey Ifra, I was reading all the responses and comments trying to figure out how I can add icons just to certain articles. I don't want to use the article id way, because we'll probably be posting a good bit of content that we'd like the icon applied to, which would mean we'd have to go add the article id code every time. I'm actually trying to add the lock icon that shows up on the "internal" articles to other articles in our HC that are considered internal, but since they have custom permissions, the icon doesn't show up. Do you have any ideas for me? PS -- I saw a link above that mentioned adding different icons to various articles, but when I clicked on it, the post was gone.
0
Ifra Saqlain
Hi Ashley Boose, icon will be show on the template if your article's setting is
Visible to only Agents and Admin.
And your section template has this code snippet for lock icon.
If any query feel free to ask.
Have a good day! :)
0
Ashley Boose
Thank you Ifra for your quick response! I understand that the lock icon will show up when article is visible to Agents and Admins only, and ours does this. However, we have created a custom segment called "Gated Access" that is visible to Agents and Admins AND a few other specific end-users that are partners of our company. We would like to be able to flag these articles as internal as well, but of course the lock icon doesn't show up for these articles. Also, there is no way to identify these articles, that I know of, in order to add the icon via Javascript or anything else. Do you have any ideas for me on this? Even if I just wanted to manually add the icon in each article title, I can't think of a way to add one that would work unless it's a symbol and even then it looks like this: 🔒.
0
Ifra Saqlain
Hi Ashley Boose,
If you added a "Labels" to your articles for your "Gated Access" users I mean like this,
add the script code to the script.js file at the bottom area,
then check the label with the given code by adding to category, section and article page same as I shared the screenshots,
Try this and let me know :)
Thanks
0
Ashley Boose
Hey Ifra, thank you so much for helping me with this, I really appreciate it. I am having one issue though. I added the code as you said, but I think instead of showing the icon on the article with the specific label, it is showing the labels for each article next to the titles for any/all articles that have them. (Screenshots of section page and article below).
0
Ifra Saqlain
Hey Ashley Boose
Add this script code to your script.js file at the bottom as well (I have mentioned in my above comment):
and make sure your document_head.hbs file has this CDN like below:
If any confusion, let me know :)
0
Ashley Boose
Hey Ifra, I have added all the code as you said. I added the following to my script.js file:
I added the following to my section, category and article pages in the place(s) that you specified:
Then I added the following to the document_head.hbs file:
Now the lock icon IS showing up on the article where that label has been added, but the only problem I'm still having is that all the other articles that have other labels are showing the label names by the titles in the category, section and article pages as well. (See screenshots.) From what I listed above, can you tell what I could've done to make this happen?
0
Ifra Saqlain
Hey Ashley Boose,
Remove previous line of code and use this code snippet:
0
Ashley Boose
Ifra, you're amazing! That worked perfectly. I appreciate you taking the time to help me with this so much--you have no idea. Thank you, thank you!
0
Ifra Saqlain
Glad to hear that it worked for you!
0
Marsy
Hello, I am trying to add icons to sections before the title name. Do you happen to have any suggestions on coding for this? I tried a few variations that are not working for me.
0
Ifra Saqlain
Hi Marsy,
There is easy and simple way,
Go to the section_page.hbs file.
Check the section id.
Add icon on section page like below:
If any confusion let me know :)
Thanks
0