Search

Does anybody have an example of how the delegate should work? I've been having problems with;

public function getSubscribedDelegates() {
            return array(
                array(
                    'page'      => '/frontend/',
                    'delegate'  => 'MobileRedirection',
                    'callback'  => array(
                        'url'       => &$url,
                        'devices'   => &$devices,
                        'result'    => $result
                        )
                ),
            );
        }

From the Extension class docs the callback in your array should contain a string, which is a public method in your extension driver. For example:

array(
    'page'      => '/frontend/',
    'delegate'  => 'MobileRedirection',
    'callback'  => 'doMyRedirect'
)

And your callback method:

public function doMyRedirect($context) {

}

Inside this method $context will hold whatever has been passed from the MobileRedirection delegate call.

I'm trying to use this extension for our site and want to enable the redirect functionality. Currently my mobile site is using the same Symphony installation and I just have a page named "m".

When I enter "m" or "/m" in my "Redirect URL" preferences, I get a "too many redirects" sort of message on the iPhone.

Am I doing this right? Is there a way to "disable" the redirect on the mobile page itself? Or should it do that automatically?

Under 'Redirect URL' try entering http://url.com/m or http://localhost/symphonyinstallation/m ignore, that seems to do the same... i am using http://m.domain.com

see http://getsymphony.com/discuss/thread/38410/#position-17

Thanks Nick, appreciate the explanation.

@TheJester12, I was having a simalar problem with the too many redirects when trying to redirect to a mobile page, i.e. mydomain.com/m. I solved it with the following lines of code in the extension.driver.php

$pageURL = 'http';
        if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
            $pageURL .= "://";
        if ($_SERVER["SERVER_PORT"] != "80") {
            $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
         } else {
            $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
         }

        $pageURL = rtrim($pageURL, "/");
        $url = rtrim($url, "/");
        if($can_redirect && $pageURL != $url){
            redirect($url);
        }

This code tests to see whether the current URL is the redirect URL. If it is then it doesn't do the redirect. I also removed the trailing slash before doing the comparison in case the user forgets to include it in the preferences section. Credit for getting the current URL in php is here

Hope this helps

Thanks bunches!

Hey Dave, I'm curious if you could be more specific as to where and how to use your code above? I tried adding it awhile ago with no avail. Is this something that could be added to the extension as a pull request?

@TheJester12 In the custom preferences in the backend I put this for the Redirect URL

http://www.mydomain.com/mobile/

Then in the extensions.driver.php I replaced the line (I think line 132):

if ($can_redirect) redirect($url);

with:

$pageURL = 'http';
        if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
            $pageURL .= "://";
        if ($_SERVER["SERVER_PORT"] != "80") {
            $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
         } else {
            $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
         }

        $pageURL = rtrim($pageURL, "/");
        $url = rtrim($url, "/");
        if($can_redirect && $pageURL != $url) redirect($url);

When I get a spare minute I'll put in a pull request but I'd bit interested to know if you get this working.

I still have problems using this code. I get a "too many redirects" message when I visit the page on my iPhone. My mobile page is a typical symphony page. I tried naming it "m", and I tried naming it "mobile", but both end up with url's like http://website.com/m/m/m/m/m/m/m/m/m... you get the idea.

Appreciate the help!

Hmmm, it looks like what might be happening is that the variables $pageURL and $url never become equal when you are on your mobile page. If they do not become equal then you will end up in the redirect infinite loop.

Can you comment out the last line of code:

if($can_redirect && $pageURL != $url) redirect($url);

and just echo out $pageURL and $url ? Something like:

echo($pageURL); 
echo($url);

Then visit your mobile page and see if these two variables are the same. If they are not can you post them up so I can see them?

Any progress with the above?

I have a multilingual site and think there might be a conflict/firing order issue with the redirects here.

EDIT The code from the solution to this issue on the Symphonists github version seems to have solved it: https://github.com/symphonists/mobiledevicedetection/issues/4

If I use the ?not-mobile cookie to set a no redirect cookie but I want to re-enable the ability to detect mobile again on the page for whatever reason what's the best approach to do this?

Is it worth adding a query such as ?redirect=not-mobile and ?redirect=mobile so that the cookie can be cleared as such or does this already exist?

EDIT Looked in driver extension file and think the ?is-mobile allows the redirect to be re-enabled I'm guessing right?

Is there a 2.3 compatible version in the pipe?

This extension is in the symphonists Github account so doesn't have a single owner. If you'd like it to be updated for 2.3 your best bet will probably be to install and try it yourself, then post any errors to the issue tracker. Once people know there is demand, there's more chance of someone stepping in to finish the update.

This might be interesting for you guys, too:

detectmobilebrowsers.com (all kinds of scripts, including apache htaccess rules)

Also check the about page:

Tablets

Android tablets, iPads, Kindle Fires and PlayBooks are not detected by design. To add support for tablets, change android.+mobile and ip(hone|od) to android and ip(ad|hone|od) and add |playbook|silk to the first regex.

This seems to be broken for 2.5.x

The datasource is created but nothing is added. Also the the preferences for this extension seem to be buggy/broken.

I've taken a look at the git files but with poor php knoledge and no idea where to start looking for possible changes between the symphony versions that might cause this issues, I am lost.

Any hints for a php beginner?

I don't really have time to test it out but usually if you go in the datasource and replace grab with execute it should be a good start. Grab has been deprecated a while ago so that could easily be why you're not seeing any output. If that doesn't work let me me know maybe someone will have a quick look into it.

Thanks gunglien for trying to help!

Just switching to execute did not make it work, though.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details