최근 검색


최근 검색 없음

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개

댓글을 남기려면 로그인하세요.

원하는 정보를 못 찾으셨나요?

새 게시물