Joomla!関連のTipsなど。
- Joomla! Tips
- 参照数: 4148
テンプレートごとに違いはあると思いますが、メニューや記事のオプションで「カテゴリの説明」を表示にしていると、 カテゴリの説明が表示されるDIVが出力されます。
<div class="contentdescription clearafter"> <p>Joomla!関連のTipsなど。</p> </div>
このテンプレートだとこんな感じ。
ところが、このDIVはカテゴリの説明の内容があるかないかは一切考慮していないので、空のDIVが出力される場合があります。
スタイルを何も指定いない場合は余り気になりませんが、枠や背景を指定している場合は気になることも。
というわけで、このDIV自体出力されないようにします。
修正するファイルの場所は、
- /Joomla!のルートフォルダ/templates/テンプレート名/html/com_content/category/blog.php
多分このあたりです。このファイルに、
<?php if ($this->params->get('show_description', 1) || $this->params->get('show_description_image', 1)) :?> <div class="contentdescription clearafter"> <?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?> <img src="<?php echo $this->category->getParams()->get('image'); ?>"/> <?php endif; ?> <?php if ($this->params->get('show_description') && $this->category->description) : ?> <?php if ($jsnUtils->isJoomla3()): ?> <?php echo JHtml::_('content.prepare', $this->category->description, '', 'com_content.category'); ?> <?php else : ?> <?php echo JHtml::_('content.prepare', $this->category->description); ?> <?php endif; ?> <?php endif; ?> </div> <?php endif; ?>
このテンプレートではこんなコードが。
$this->paramsというのは、表示設定が格納されている連想配列のようです。1行目は「カテゴリの説明」か「カテゴリイメージ」が表示になっていたらという判定。
「カテゴリの説明」の実体は、$this->category->descriptionで、「カテゴリイメージ」の実体は、$this->category->getParams()->get('image')のようです。なので、以下のように書き換え。
<?php if ($this->params->get('show_description', 1) || $this->params->get('show_description_image', 1)) :?> <?php if ($this->category->description || $this->category->getParams()->get('image')) :?> <div class="contentdescription clearafter"> <?php endif; ?> <?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?> <img src="<?php echo $this->category->getParams()->get('image'); ?>"/> <?php endif; ?> <?php if ($this->params->get('show_description') && $this->category->description) : ?> <?php if ($jsnUtils->isJoomla3()): ?> <?php echo JHtml::_('content.prepare', $this->category->description, '', 'com_content.category'); ?> <?php else : ?> <?php echo JHtml::_('content.prepare', $this->category->description); ?> <?php endif; ?> <?php endif; ?> <?php if ($this->category->description || $this->category->getParams()->get('image')) :?> </div> <?php endif; ?> <?php endif; ?>
これでOKです。