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.

Drupalで見ているページのQRコードを表示する

mobile_codes というDrupalのモジュールを使って、今見ているページのQRコードを左サイドバーに表示してみた。

用途としては、見ているページをあとで携帯から見たいと思ったときに簡単にリンクを送れるということを想定している。

以下の手順でできた。

1.mobile_codes モジュールを導入する。
2. 表示用のブロックを作成する。内容はなんでもいいからダミーを入れておく。というのは、実際の表示は、block-block-{id}.tpl.php を使って行うため。
3.2で作成したブロックのidを調べる。一度表示させて、そのページのソースを見てみる。すると、該当箇所に以下のようになっているはず。

<div id=”block-block-3″ class=”block block-block”><div class=”block-inner”>

この場合、ブロックのid が”block-block-3″なので、block-block-3.tpl.php というファイルを作成すれば、このブロックだけに適用される。

デフォルトの block.tpl.php (themes/engines/phptemplate/block.tpl.php)を、使用しているテーマの下に、block-block-{id}.tpl.php という名前でコピーする( id は上で調べた数字)。ブロックの中身を表示している以下の記述がある。

<?php print $block->content; ?>

これを以下に置き換える。

‘thisnode’, ‘data’ => ‘link’, ‘type’ => ‘qr’, ‘size’ => ‘small’);
print theme_mobilecode($path, $arguments). ‘
‘. $path;
?>

これでできあがり。(http://nyanchew.com/ のところはWEBアクセスのベースのURLに書き換えてください)

mobile_codes モジュールは、QRコードの生成を http://mobilecodes.nokia.com/ というノキアのサービスを使って行っている。

3件のコメント

  1. 助かった?ありがとう
    モバイルコードモジュールの使い方にとっても頭が痛いときに、
    この文章を勉強しました。
    本当に助かりました?!
    ありがとうございました。

    上の文章を翻訳して、中国語の私のブログに転載しました。
    わがままで申し訳ないですが、
    いい文章ですから、許すをもらわなくても、とても転載したいです。

    ありがとう?

  2. コメント

    -は?になっちゃって、なぜでしょうか
    -は?になっちゃって、なぜでしょうか

    1. nyanchew コメント

      おそらくMySQL の comments テーブルがSJISになっていたため
      utf8-general-ci に直しました。たぶん、これで大丈夫。

      参考:
      http://nyanchew.com/mysql-utf-8

コメントは受け付けていません。

PAGE TOP