I have next to no experience with php as a language, and am running it a little problem in producing a Drupal theme. What I need is to execute a function once, that will return a Boolean, then use that Boolean throughout the template.
Here is what I have so far:
html.tpl.php->
<?php
function testMobile(){
return false;
}
define('isMobile', testMobile());
?>
...
<?php
if(!isMobile){
echo '<h1>NOT MOBILE</h1>';
}else{
echo '<h1>IS MOBILE</h1>';
}
?>
page.tpl.php->
<?php
if(!isMobile){
echo '<h1>IS DESKTOP</h1>';
}else{
echo '<h1>NOT DESKTOP</h1>';
}
?>
In the drupal output I get this ->
NOT MOBILE
NOT DESKTOP
along with this error message:
Notice: Use of undefined constant isMobile - assumed 'isMobile' in include() (line 77 of /Users/#/#/#/sites/all/themes/#/templates/page.tpl.php).
what am I doing wrong here? How can I most easily achieve my goal?