[Solved]Mobile Detect plugin won't work

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
brutusmaximus
Forum Members
Forum Members
Posts: 23
Joined: Tue Apr 02, 2013 1:15 pm
Location: 's-Hertogenbosch

[Solved]Mobile Detect plugin won't work

Post by brutusmaximus »

Hi there! I'm currently trying to implement a mobile detect php script, so that mobile user will get a light version of a slideshow.

PHP Mobile Detect Script: http://mobiledetect.net/
1. I placed the PHP script in the folder: /mdetect/MobileDetect.php
2. Created a plugin (see below) /plugin/function.mobile_detect.php
3. when I call {mobile_detect} my website only is displaying the html till the placed tag. No stylesheets are generated.

Code: Select all

<?php

function smarty_function_mobile_detect($params, $smarty)
{
include_once('/mdetect/Mobile_Detect.php');
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
$smarty->assign('deviceType', $deviceType);

 }
?>
My steps to solve the problem:
1. Smarty 3 include php guide: http://www.smarty.net/best_practices
2. Smarty debug = true (isn't generating any output) :(

3. Posting a forumpost ;) pls help
Last edited by brutusmaximus on Fri May 17, 2013 4:34 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Mobile Detect plugin won't work

Post by calguy1000 »

When working in PHP you need to be able to find, see, and interpret error messages. Check your error logs.
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.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Mobile Detect plugin won't work

Post by Rolf »

Why not use CGExtentions module?

Code: Select all

{cge_is_smartphone assign='is_mobile'}
{if $is_mobile}
...
{else}
...
{/if}
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
brutusmaximus
Forum Members
Forum Members
Posts: 23
Joined: Tue Apr 02, 2013 1:15 pm
Location: 's-Hertogenbosch

Re: Mobile Detect plugin won't work

Post by brutusmaximus »

Thanks for quick reply.

@Rolf wow that's a quick and great solution. Didn't know you'd could do that with cgextensions

@calguy great tip, now I'm looking for the logs :-\
brutusmaximus
Forum Members
Forum Members
Posts: 23
Joined: Tue Apr 02, 2013 1:15 pm
Location: 's-Hertogenbosch

Re: Mobile Detect plugin won't work

Post by brutusmaximus »

Errorreporting enabled in the htacces

Code: Select all

php_flag register_globals On
# Level of log detail - log all errors
php_value error_reporting -1

# Write errors to log file
php_flag log_errors On

# Do not display errors in browser (production - Off, development - On)
php_flag display_errors On

# Do not display startup errors (production - Off, development - On)
# php_flag display_startup_errors Off

# Format errors in plain text
# Note: Leave this setting 'On' for xdebug's var_dump() output
php_flag html_errors On
Now it displays a error. (nice lessons learned here) ;)

Warning: include_once(/home/vhosting/h/../plugins/mdetect/Mobile_Detect.php) [function.include-once]: failed to open stream: No such file or directory in /home/vhosting/h/.../plugins/function.mobile_detect.php on line 5

Warning: include_once() [function.include]: Failed opening '/home/vhosting/h/.../plugins/mdetect/Mobile_Detect.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/vhosting/h/../plugins/function.mobile_detect.php on line 5

Fatal error: Class 'Mobile_Detect' not found in /home/vhosting/h/.../plugins/function.mobile_detect.php on line 6

Now googling for a solution!
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Mobile Detect plugin won't work

Post by Rolf »

brutusmaximus wrote:Now googling for a solution!
The error message seems clear to me...
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
brutusmaximus
Forum Members
Forum Members
Posts: 23
Joined: Tue Apr 02, 2013 1:15 pm
Location: 's-Hertogenbosch

Re: Mobile Detect plugin won't work

Post by brutusmaximus »

Rolf wrote:
brutusmaximus wrote:Now googling for a solution!
The error message seems clear to me...
hahahahha yes the file was in the wrong directory ;)
I thought when you refer to a /dir/folder/file.php it's a absolute path. But for PHP it means the refered file should be in the same folder.


thanks @calguy and @rolf
Locked

Return to “Modules/Add-Ons”