Multiple Instances of Promoted Articles
RespondidaI was wondering if there was a way to have more than one promoted article instance. I tried doing this by adding " {{promoted_articles}}" again but then realized this just doubles the existing. There would have to be something along the lines of "{{promoted_articles-1}}". I'm not sure if this is feasible as that tag seems to connect to something under the hood I can't access. We are trying to create a promoted section for release notes articles and a separate for new features articles.
-
@James - You can have multiple promoted articles on the page but you would need some type of wording like "Feature Request" and some JQuery to only show those articles. It is possible but would take some development.
-
Yea I guess the JQuery part is where I am fuzzy. I can dig around and see if I can figure out how to get this going.
-
@James - I'm pretty busy but if I get some time I'll send some code your way. I have something similar implemented in my Help Center so I'll see if I can dig it out.
-
Thanks! That would be awesome. No rush. Much appreciated!
-
Hi Wes,
Was just checking up on that code if you get a change. Thanks!
-
@James - Haven't had much time but maybe it will help if you kinda layout some details. On your homepage you would like to show promoted articles in two different places, could you label the article with a keyword at the beginning which I could hide if needed. For example "Hot Topics- Promoted Article 1" an then "Feature Request - Promoted article 2".
-
I have attached a screen shot of what we have now. I took some script from another post and changed the name of the first promoted articles section. I was hoping we could get another instance next to this titled "New Features" where we could promote feature articles.
-
@James - give this a shot.
HTML - add the following on your home page.
<div class="PR1">
{{promoted_articles}}
</div>
<div class="PR2">
{{promoted_articles}}
</div>
CSS - add the below lines
.promoted-articles a {
display: none;
}
JS - add the below lines
//Change text of Promoted Articles
$(".PR1 h3:contains('Promoted articles')").text('Releases');
$(".PR2 h3:contains('Promoted articles')").text('Feature Request');
if ( $('div.PR1 a:contains("Release")').length > 0 ){
$('div.PR1 a:contains("Release")').show();
}
if ( $('div.PR2 a:contains("Feature Request")').length > 0 ){
$('div.PR2 a:contains("Feature Request")').show();
}
Now go into your articles and add the word Release or Feature Request in the title an it should show up under the correct one.
I threw this together quickly so I'm sure there's a more efficient way to code this but this was the quick and dirty way.
Let me know how it goes.
-
Hmmm I got as far as below. I have added Release to one of the titles of the articles and it's now showing up. I do appreciate the help on this, but if we have to have those phrases in all promoted articles titles I don't think this is something we can use though.
-
@James - Once you get it working we can hide those words but they have to be there as that is the only way it knows how to show. If you provide me with a link to your Help Center then I can see what you have as I tested the solution on a base Humble Squid theme and it worked perfect.
-
Ahh ok that's cool. Link - https://support.breadcrumb.com/hc/en-us
I'm probably putting the code in the wrong spots or something. I know just a touch of such things. I didn't save the new code to the environment was just working in preview.
-
@James - Any way you can add the code and save it so that I can see or will that mess you up.
-
I got the code added in and saved for you. Thanks again!
-
@James - Move the javascript that I have above right below the $(document).ready(function() and that should do it.
-
@Wes - I've been working with James on trying to get this working. I used your code and moved the javascript snippet below the $(document).ready(function()) but we still can't get both instances next to each other. Any additional help would be greatly appreciated!
-
@Octavian - Are you wanting the Releases and Feature Request side by side? Is that what you are wanting? if so that should just be a little CSS. Is all the JS code working correctly?
-
@Wes - I'm still having trouble with the JS code splitting up the articles. I added "Feature" to the title of this article https://support.breadcrumb.com/hc/en-us/articles/204403613 but I can't get it to show up under the "Feature Request" section. Feel free to take a look if you have some time.
-
@Octavian - You will need to mark that article as Promoted.
-
@Octavian - Also you will need to uncomment that CSS (the very last line in your CSS file) and you can change the PR1 code below:
if ( $('div.PR1 a:contains("Version")').length > 0 ){
$('div.PR1 a:contains("Version")').show();
}
If it finds the word version then it will show those under the Releases. I tested this in the browser and it worked. Once you make those changes let me know and I'll take another look.
-
@Wes - Thanks for all the help! I changed the PR1 code, uncommented the CSS, and marked the article as promoted.
-
@Octavian - You have an error in your JS file. When you added the PR1 information you didn't include the last bracket. Look at my code above and add the }
-
@Wes - D'oh! Sorry about that. It's showing up under the correct sections now. Thanks again for all your help! You had also mentioned that there is a way to hide "Feature" from the title of each article, is that correct?
-
This post closed for comment by the Zendesk Community Team. If you have a related or new question, please create a new post.
Publicação fechada para comentários.
23 Comentários