php code displaying on site - whats wrong?

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Locked
earcandy
Forum Members
Forum Members
Posts: 58
Joined: Sat Jan 11, 2014 4:37 pm

php code displaying on site - whats wrong?

Post by earcandy »

I added the following php code to my template in order to redirect mobile users to my mobile site.

It works great but I can see some of the code on the main webite.

"window.location=’https://californiaschooloflaw.com/admin/mobile/'”; } ?>"

What did I miss and how can I correct this?

Code: Select all

<head>
<?php
$iphone = strpos($_SERVER[‘HTTP_USER_AGENT’],”iPhone”);
$android = strpos($_SERVER[‘HTTP_USER_AGENT’],”Android”);
$palmpre = strpos($_SERVER[‘HTTP_USER_AGENT’],”webOS”);
$berry = strpos($_SERVER[‘HTTP_USER_AGENT’],”BlackBerry”);
$ipod = strpos($_SERVER[‘HTTP_USER_AGENT’],”iPod”);

if ($iphone || $android || $palmpre || $ipod || $berry == true) 
{
    echo “<__script__>window.location=’https://californiaschooloflaw.com/admin/mobile/'</__script>”;
 }
?>
 
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: php code displaying on site - whats wrong?

Post by Dr.CSS »

I think that should be in a UDT but w/o the open/close PHP partand if you really want to have raw PHP in your template I think there is a setting for that in the site admin or it is a setting/parameter in the config.php...

I don't know if this is it but it turns out there is no setting in site admin to let you use raw PHP in templates...

#Allow smarty {php} tags? These could be dangerous if you don't trust your users.
$config['use_smarty_php_tags'] = false;

I think that you can use either CGSimpleSmarty or CGExtensions to do a mobile check for redirect, I used a bit of JS for it myself...
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: php code displaying on site - whats wrong?

Post by calguy1000 »

The use_smarty_php_tags stuff was removed from CMSMS in 1.11
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Locked

Return to “Layout and Design (CSS & HTML)”