Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

Mobile用テーマへの切り換えリンク

[追記] アクセスする端末に応じたテーマの切換については、SwitchTheme をやめて Mobile Tools を使うことにしました。

Android端末を使い始めてから自分では Mobile用のテーマは必要ないのだが、いちおうこのサイトではブラウザのUAを見てモバイル用のテーマに切り替わるようになっている。そのために、MobileTheme というモジュールを使っていたのだが、 これを SwitchTheme というモジュールに切り替えた。

SwitchTheme を使うと、有効になっているテーマをユーザが切り替えて使えるようになる。テーマ切り換え用のブロックメニューを作りサイドバーなどに置くのが通常の使い方のようだ。ここでは、Mobile用 と PC用を切り換えるだけなので、ブロックメニューではなく画面の一番下に切り換え用リンクを置くことにした。

PC用テーマで見ているときは、Mobile用テーマへの切り換えリンクが現れ、逆に Mobile用テーマで見ているときはPC用テーマへの切り換えリンクが現れる。

通常のモジュールと同じようにインストールし、ユーザ権限の設定を行って匿名ユーザでも切り替え機能を使えるようにする。

次に、PC用テーマとMobile用テーマのそれぞれで互いに相手に切り換えるためのリンクを表示してやればよい。SwichThemeを有効にしていると URL に ‘?theme=‘ を付加することでテーマを切り換えることができる。この機能を利用するために template.php に以下の関数を入れた。

function nyanchew_preprocess_page(&$vars, $hook) {
$vars[‘footer_message’] = l(‘Change to Mobile theme’, $_GET[‘q’], array(‘query’ => ‘theme=mobile’)$
}

ここでは footer に ’Change to Mobile theme’ という文字列でモバイルテーマへの切り換えリンクを表示している。

さらに、SwitchThemeはBrowsecap モジュールと連動し、ブラウザのUAを見てテーマを指定することもできるので、DoCoMo、KDDI、NetFrontといったブラウザはMobile用テーマで表示するようにしてみている。

PAGE TOP