I only want to show the "Switch back to mobile view" link to mobile users only on the desktop theme.
So it should not be displayed to desktop users.
I think the best way to implement this is to add something like this to my page.tpl.php on the desktop theme:

if ( $_SESSION['mobile_subdomain']['noredirect'] ) {
print 'Switch back to mobile view';
}

Is this the right way for this?
Thank you!

Comments

saltednut’s picture

Please post a patch. :)

saltednut’s picture

Category: Support request » Feature request
Issue summary: View changes
saltednut’s picture

Category: Feature request » Support request
Status: Active » Postponed (maintainer needs more info)

Oops sorry I should have read closer. This was a support request. My bad!

You are close.

You'd want the code to be:

if (isset($_SESSION['mobile_subdomain']['noredirect']) && $_SESSION['mobile_subdomain']['noredirect'] != FALSE) {
  print '<a href="http://example.com/mobile-subdomain-redirect/true">Switch back to mobile view</a>';
 }

This way you can ensure that variable is available and TRUE. The code you posted may work, but its my preference to be a little more verbose here as you are assuming the variable is available and it may not be, which could cause an exception.

Please mark this as fixed if it fixes your issue.

perohu’s picture

Status: Postponed (maintainer needs more info) » Fixed

Thx

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.