Body: <p>I want to display different code blocks if a category level is 1 or 2 or 3 – on a category page, but finding this hard to do, 
  if I'm on an entry page I can use:</p>
  
  <pre><code>{% if entry.level == 1 %}
  </code></pre>
  
  <p>how can I use the equivalent but for a category on a category page?
  Thanks</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-28T11:13:00.597Z
Comments.Text: Did you tried this: https://docs.craftcms.com/v3/dev/element-queries/category-queries.html#parameters ?
Comments.UserDisplayName: Romain P.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-29T12:24:42.660Z
Comments.Text: Thank you, I need to update this post as my code must have been wrong as – the simple line:   
  ```{% if category.level < 2 %}``` does work!
Comments.UserDisplayName: user2569
Tags: <categories>
Title: Conditionally test for a category level
ThreadText: # Conditionally test for a category level
  
  (Asked by: username_0 on 2019-11-27)
  
  I want to display different code blocks if a category level is 1 or 2 or 3 – on a category page, but finding this hard to do,
  if I'm on an entry page I can use:
  
  ```
  {% if entry.level == 1 %}
  
  ```
  
  how can I use the equivalent but for a category on a category page?
  Thanks
  
  **Tags:** categories
  
  > **Comments:**
  > **username_1**: Did you tried this: https://docs.craftcms.com/v3/dev/element-queries/category-queries.html#parameters ?  
  > **username_0**: Thank you, I need to update this post as my code must have been wrong as – the simple line:    ```{% if category.level < 2 %}``` does work!  
  
  ---
  
  ## 0 answers
  
  