HTMLテンプレートをJoomlaテンプレートに変換しています。 HTMLに次のブロックがあります。
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
この条件ステートメントをJDocumentオブジェクトに入れる最良の方法は何ですか?
私は以下がうまく機能すると信じています:
<?php $doc = JFactory::getDocument(); ?>
<!--[if lt IE 9]>
<?php
$doc->addScript('https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js');
$doc->addScript('https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js');
?>
<![endif]-->
$doc
はステートメントの外で定義したことに注意してください。
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<jdoc:include type="head" />
お役に立てれば
JDocument(実際にはJDocumentHTML)には隠しメソッドaddCustomTag
があるようです。
$customTag = <<<CUSTOM
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
CUSTOM;
$doc->addCustomTag($customTag);