Idhae
Active member
I need some variables in the visitor object for later template conditions.
Actually i make a:
code event listener: visitor_setup
ERROR:
In Xenforo 1.5 this was working good. Can someone help?
If someone have a better idea to do that, say it to me.
Final it should work like this for example:
Actually i make a:
code event listener: visitor_setup
PHP:
<?php
namespace My/Addon;
use My/Addon/Mobile_Detect;
class Listener
{
public static function visitorSetup(\XF\Entity\User &$visitor)
{
/* Mobile_Detect to visitor Objekt */
$is_mobile = $detect->isMobile();
$is_smartphone = $detect->isMobile() && !$detect->isTablet();
$is_tablet = $detect->isTablet();
$visitor ['is_mobile'] = $is_mobile;
$visitor ['is_smartphone'] = $is_smartphone;
$visitor ['is_tablet'] = $is_tablet;
}
}
ERROR:
Code:
An exception occurred: [InvalidArgumentException] Column 'is_mobile' is unknown in src/XF/Mvc/Entity/Entity.php on line 536
In Xenforo 1.5 this was working good. Can someone help?
If someone have a better idea to do that, say it to me.
Final it should work like this for example:
HTML:
<xf:if is="!$visitor['is_smartphone']">
show content desktop
</xf:if>
Last edited: