1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

template parameter for a CATEGORY

Discussion in 'Styling and Customization Questions' started by Weppa333, Jun 3, 2013.

  1. Weppa333

    Weppa333 Active Member

    Hello

    This is my first message in XF1.2 :)

    I would like to find a way to create a conditional, in a template, to know whether or not I'm in a CATEGORY, and the category name/ID

    I found template parmas [forum][node_id] but it seems it is NOT filled up when inside a category.

    I cannot find the right template parameter for a category. can anyone help ?
     
  2. Weppa333

    Weppa333 Active Member

  3. Brogan

    Brogan XenForo Moderator Staff Member

    It does work but you need to have categories set as pages.
     
  4. Weppa333

    Weppa333 Active Member

    I did,
    I can assure you $category is empty,
     
  5. Brogan

    Brogan XenForo Moderator Staff Member

    Weppa333 likes this.
  6. Weppa333

    Weppa333 Active Member

    I'll try, It's not really in a page per-se, it's as a conditionnal for widgetframework that I'm trying to use it.
    I basically want the widget to activate only when in a specific category
     
  7. Weppa333

    Weppa333 Active Member

    I can assure you that
    <xen:if is="{$category.node_id} == 1">
    This content will show in category 1
    </xen:if>

    never show on category 1, with category as pages activated.

    Same with xen:container using another variable,
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    I can assure you it does, I have just tested it on my local to confirm.
    I edited the category view template and added that very code.

    category_view.PNG

    It shows in category 1 only and nowhere else.
     
  9. Weppa333

    Weppa333 Active Member

    I must be doing something wrong. I'll try again and again :) .
     
  10. Brogan

    Brogan XenForo Moderator Staff Member

    Does your category actually have an ID of 1?

    Check the URL, the ID value is at the end.
     
  11. Weppa333

    Weppa333 Active Member

    Okay I finally made it work,
    $category.node_id is available only in category_view, nowhere else. This is the key to make it work.

    Thanks @Brogan !
     
  12. Brogan

    Brogan XenForo Moderator Staff Member

Share This Page