Recent searches
No recent searches
Tip: How to get the category/section/topic ID using breadcrumbs?
Zendesk LuminaryMost Engaged Community Member - 2022Most Engaged Community Member of The Year - 2021Community Moderator
Posted Jul 31, 2021
Prerequisite:
Templates: category, Section, Article, Community Post
Use: Random
Hi to all,
Here, I am sharing a simple tip that if anybody need in urgent call like middle of the customization project so he/she can use this. The given regex can be used to get the IDs from the breadcrumbs and user can check the IDs with 'if' condition and do something using JS, etc.
To get category ID from breadcrumbs.
<script>
var getID = $('.breadcrumbs li:nth-child(2) a').attr('href').match(/[0-9]+/)[0]
</script>
To get section ID from breadcrumbs.
<script>
var getID = $('.breadcrumbs li:nth-child(3) a').attr('href').match(/[0-9]+/)[0]
</script>
The above script code need to add on the template inside the script tags.
There are another ways to get the IDs by search-bar as in my previous post and this one is also from those ways :)
Thanks
3
0
0 comments