Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4005878
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:26:50+00:00 2026-05-20T08:26:50+00:00

I’ve been trying to get mobile_tools for Drupal 7 to work but it appears

  • 0

I’ve been trying to get mobile_tools for Drupal 7 to work but it appears it’s not switching themes. (Or at least I can’t get it to switch).

This is the code “in charge of changing to the mobile theme. If I print $custom_theme it does become the name of the mobile theme but the displayed theme is still the default. I have not been able to find any documentation on variable $custom_theme at least not for Drupal 7.

/**
 * Being called in the hook_boot() implementation
 * This function is in charge of changing to the mobile theme
 */
function mobile_tools_switch_theme($device) {
 global $custom_theme, $conf;
 // check if theme switching is forced
 $current_url_type = mobile_tools_is_mobile_site();

 if (($current_url_type == 'mobile' &&  variable_get('mobile-tools-theme-switch', ''  ) == 'mobile-tools-mobile-url') || 
   (variable_get('mobile-tools-theme-switch', ''  ) == 'mobile-tools-mobile-device' && $device['type']  == 'mobile') ) {
  $group = $device['group'];
  $mobile_detection_module = variable_get('mobile-tools-device-detection', 'mobile_tools');
  if (variable_get($mobile_detection_module . '_' . $group . '_enable', '') == 1) {
   $custom_theme = variable_get($mobile_detection_module . '_' . $group . '_theme', $conf['theme_default']);
   return TRUE;
  }
  else {
   $custom_theme  = variable_get('mobile_tools_theme_name', $conf['theme_default']);
   return TRUE;
  }
 }
 return FALSE;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:26:51+00:00Added an answer on May 20, 2026 at 8:26 am

    $custom_theme is no longuer the way to switch themes in Drupal 7 as mentionned in the Upgrade modules from 6.x to 7.x page, you have to use hook_custom_theme or specify a theme callback for the path instead.


    Example from the upgrade page:

    <?php
    /**
    * Implements hook_menu_alter().
    */
    function mymodule_menu_alter(&$items) {
      // Set the theme callback function for all node pages. As per the
      // standard behavior for hook_menu() properties, this will be
      // inherited by all paths underneath node/%node as well, unless
      // they define their own theme callback.
      $items['node/%node']['theme callback'] = 'mymodule_default_node_theme';
    
      // Set a different theme callback for node edit pages, and pass
      // along the node object to this function so we can make decisions
      // based on it.
      $items['node/%node/edit']['theme callback'] = 'mymodule_edit_node_theme';
      $items['node/%node/edit']['theme arguments'] = array(1);
    }
    
    /**
    * Defaults to using the 'some_theme' theme for node pages.
    */
    function mymodule_default_node_theme() {
      return 'some_theme';
    }
    
    /**
    * For editing page nodes, uses the 'some_other_theme' theme.
    */
    function mymodule_edit_node_theme($node) {
      return $node->type == 'page' ? 'some_other_theme' : mymodule_default_node_theme();
    }
    
    /**
    * Implements hook_custom_theme().
    */
    function mymodule_custom_theme() {
      global $user;
      // If the current user has a special role assigned to them, then display all
      // pages of the site (including those listed above) using the 'special_theme'
      // theme.
      if (in_array(variable_get('mymodule_special_role', 0), array_keys($user->roles))) {
        return 'special_theme';
      }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.