このモバイル検出phpファイルをmagento Webサイトで使用したいのですが、magentoの構造はまだ少し難しいので、phpファイルを挿入して他のサブテンプレートで使用する最良の方法を知りたいです。
基本的に、このmain-template.phtmlとheader.phtmlのようなものがあります
main-template.phtml コンテンツは
<?php
include_once 'Mobile_Detect.php';
$detect = new Mobile_Detect();
echo $this->getChildHtml('head');
?>
<?php if ( $detect->isMobile() ) { //condition nr.2 ?>
<meta name="mobileMain" content="this is for mobile">
<?php } else {?>
<meta name="NOTmobileMAIN" content="this is not for mobile">
<?php } ?>
header.phtml コンテンツは
<?php if ( $detect->isMobile() ) { //condition nr.1 ?>
<meta name="mobile" content="this is for mobile">
<?php } else {?>
<meta name="NOTmobile" content="this is not for mobile">
<?php } ?>
ブラウザで main-template.phtml をロードすると、2 番目の条件が機能しますが、最初の条件で「オブジェクト以外のメンバー関数 isMobile() への呼び出し」というエラーがスローされます。
Mobile_Detect.php を main-template.phtml に一度だけ含め、main-template.phtml 内にも挿入される header.phtml のようなすべてのサブファイルでその条件を実行できるようにする最善の方法は何でしょうか?
ありがとうございました!