0

私はあまり優れたコーダーではありません。私のテクニックには、ほとんどの場合、コピーの貼り付けと、それが機能するまでの編集が含まれます。

joomla 2.5サイトのindex.phpにこのコードがあり、ホームページでのみ特定のcssスタイルを出力します。

<?php
$app = JFactory::getApplication();
$menu = $app->getMenu(); ?>
<?php if ($menu->getActive() == $menu->getDefault()): ?>
<style type="text/css">
  #contentonderaan {min-height: 462px;}
</style>
<?php endif; ?>

これは問題なく動作しますが、ホームページではないすべてのページに「else」ステートメントを使用して、代替の最小高さ css を提供したいと考えています。これは簡単ですよね?ただし、動作させることができないため、構文に問題があります。では、どのように書けばよいのでしょうか。ありがとう

4

6 に答える 6

6

機能しない構文は何ですか?

それは単にelse:.

<style type="text/css">
<?php if ($menu->getActive() == $menu->getDefault()): ?>
    #contentonderaan {min-height: 462px;}
<?php else: ?>
    #contentonderaan {min-height: YOUR_HEIGHTpx;}
<?php endif; ?>
</style>
于 2013-04-18T14:17:47.993 に答える
0

中括弧を使用できます:

<?php
    $app = JFactory::getApplication();
    $menu = $app->getMenu();
?>
<?php if ($menu->getActive() == $menu->getDefault()){ ?>
    <style type="text/css">
        #contentonderaan {min-height: 462px;}
    </style>
<?php }else{ ?>
    <!-- foo -->
<?php } ?>
于 2013-04-18T14:19:08.527 に答える
0
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu(); ?>
<?php if ($menu->getActive() == $menu->getDefault()) { ?>
<style type="text/css">
  #contentonderaan {min-height: 462px;}
</style>
<?php } else { ?>
<style type="text/css">
  #contentonderaan {min-height: 500px;}
</style>
<?php } ?>

または、使用することもできますelse:

<?php
$app = JFactory::getApplication();
$menu = $app->getMenu(); ?>
<?php if ($menu->getActive() == $menu->getDefault()): ?>
<style type="text/css">
  #contentonderaan {min-height: 462px;}
</style>
<?php else: ?>
<style type="text/css">
  #contentonderaan {min-height: 500px;}
</style>
<?php endif; ?>
于 2013-04-18T14:19:09.267 に答える