suncat2000 / MobileDetectBundle

Symfony 2/3/4 bundle for detect mobile devices, manage mobile view and redirect to the mobile and tablet version.
397 stars 154 forks source link

could device_view functionality be optionally session based? #5

Open HenriVesala opened 12 years ago

HenriVesala commented 12 years ago

Current problem is that when user visit the sit with mobile and he decides to check full page version he is stuck with full page version unless he manually switches back. I think that it would be logical to always redirect new mobile sessions to mobile page.

suncat2000 commented 12 years ago

You offer good ideas, but the next month I will have very little time. You can do PR's or I can add you to the list of collaborators. Together productively! If you are interested?

HenriVesala commented 12 years ago

Yeah. I have bit similar situation ongoing but I shall make PR's in the future if I have time. You can also add me to collaborator if you like.

HenriVesala commented 12 years ago

This feature wasn't included in my PR and is still in todo list.

suncat2000 commented 12 years ago

Ok I hastened )

gnikyt commented 11 years ago

Is this going to be added? This is an issue I had as well where the cookie kept the user on the full version and they'd have to manually switch back.

My work around for now is:

        if ($mobile_detector->isMobile()) {
            $response = new Response;
            $response->headers->clearCookie(DeviceView::COOKIE_KEY);
            $response->send();
        }

In the controller, might not be the best way but session based would definately be good!

HenriVesala commented 11 years ago

Currently I don't have any need for this feature so I think nobody is working on it. Feel free to make pullrequest if you have solution.

tobias-r commented 10 years ago

I also need this feature. Can't you guys just solve it with Cookie Lifetime?

Now we have 30 days, just change it to expire=0 and we're all set?

netmikey commented 10 years ago

I think we'd need a way to get back to the mobile view (or in other words: to the default device behaviour), regardless of cookie lifetime or whether the view overwriting is attached to the session.

I found another workaround that seems to work: I included the following at the very bottom of my "desktop" template:

{% if is_mobile() %}
    <a href="?device_view=mobile">
        To mobile version &raquo;
    </a>
{% endif %}

Thanks to the is_mobile() check, this will only ever be displayed if a mobile device displays the full version (which only happens when the view is overridden).

Applying this trick in your mobile template could also be helpful to give accidental desktop visitors a chance of reaching the corresponding full desktop page (though #43 would be nice, too :)).