Prestashop 1.7.1 | Add class to body when user is logged
A useful things that i love when develops in wordpress, is that automatically adds class to body when user is logged-in.
I use this class for styling elements that change if user is logged or not ( name in the header, or , if is an e-commerce all customer info..)
I want’s to do same thing in prestashop.
Open the layout-both-columns.tpl, and immediatly after
<head>
{block name='head'}
{include file='_partials/head.tpl'}
{/block}
</head>
replace the
tags with this one:
{if $customer.is_logged }
<body id="{$page.page_name}" class="{$page.body_classes|classnames} user_logged">
{else}
<body id="{$page.page_name}" class="{$page.body_classes|classnames}">
{/if}
Now, if you reload page, you see that if a user is logged, a class ” user_logged ” is added to body, else none class will be add.
( if you need to add class even if the user isn’t logged, simply write it in the second istance of “body” )
That’s all