Answer the question
In order to leave comments, you need to log in
How to pass php to smarty template via plugin?
Tell me how to pass this piece of php to a template built on smarty (version 3)
<?php
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
if ( $detect->isMobile() ): ?>
<p>Mobile Content</p>
<? else: ?>
<p>Default Content</p>
<? endif; ?>
Answer the question
In order to leave comments, you need to log in
"but how to pass a variable with an object to the template and how to build an if-else with it will not work in any way."
You are trying to do a terrible thing. That's how it is more or less necessary.
<?php
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
$is_mobile = $detect->isMobile();
Use your own template: it seems to be not difficult and in capable hands reduces the load on the web server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question