最近搜索


没有最近搜索

Tip: How to get the category/section/topic ID using breadcrumbs?



image avatar

Ifra Saqlain

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

已于 2021年7月31日 发布

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 条评论

请先登录再写评论。

找不到所需的内容?

新建帖子