XF 1.5 How can I add classes to the <body> tag

rhodes

Active member
#1
Hello,

I would like to add an additional css class to my body tag, depending if a user is logged in or not. I would like to use this as a selector for jquery AJAX calls.

Example logged in
Code:
<body class="node6 node16 logged-in SelectQuotable">
Example anonymous
Code:
<body class="node6 node16 not-logged-in SelectQuotable">
I hoped that I could achieve this just by modifying the page_container template, but it seems to be much more difficult.

Any ideas where to start?
 

Matt C.

Well-known member
#2
Hello,

I would like to add an additional css class to my body tag, depending if a user is logged in or not. I would like to use this as a selector for jquery AJAX calls.

Example logged in
Code:
<body class="node6 node16 logged-in SelectQuotable">
Example anonymous
Code:
<body class="node6 node16 not-logged-in SelectQuotable">
I hoped that I could achieve this just by modifying the page_container template, but it seems to be much more difficult.

Any ideas where to start?
You can follow this guide for using template conditionals. https://xenforo.com/community/resources/conditional-statements.1604/

In this case, it would be
Code:
<xen:if is="{$visitor.user_id}">
This content will show to logged in members
</xen:if>
 

Steve F

Well-known member
#3
There is already a LoggedIn/LoggedOut class provided in the <html> tag.

In the PAGE_CONTAINER template you'll find this.
Code:
{xen:if {$visitor.user_id}, 'LoggedIn', 'LoggedOut'}

upload_2017-6-25_12-17-20.png
 
Top