Skip to content

Commit

Permalink
Update category layout override.
Browse files Browse the repository at this point in the history
Update the category layout to show Joomla custom fields.
  • Loading branch information
trungch committed May 26, 2017
1 parent 790b504 commit 463db7f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,26 @@
*/

$params = $displayData->params;
$category = $displayData->get('category');
$extension = $displayData->get('category')->extension;
$canEdit = $params->get('access-edit');
$className = substr($extension, 4);

$dispatcher = JEventDispatcher::getInstance();

$category->text = $category->description;
$dispatcher->trigger('onContentPrepare', array($extension . '.categories', &$category, &$params, 0));
$category->description = $category->text;

$results = $dispatcher->trigger('onContentAfterTitle', array($extension . '.categories', &$category, &$params, 0));
$afterDisplayTitle = trim(implode("\n", $results));

$results = $dispatcher->trigger('onContentBeforeDisplay', array($extension . '.categories', &$category, &$params, 0));
$beforeDisplayContent = trim(implode("\n", $results));

$results = $dispatcher->trigger('onContentAfterDisplay', array($extension . '.categories', &$category, &$params, 0));
$afterDisplayContent = trim(implode("\n", $results));

/**
* This will work for the core components but not necessarily for other components
* that may have different pluralisation rules.
Expand All @@ -40,17 +57,22 @@
<?php echo JHtml::_('content.prepare', $displayData->get('category')->title, '', $extension.'.category.title'); ?>
</h2>
<?php endif; ?>

<?php echo $afterDisplayTitle; ?>

<?php if ($params->get('show_cat_tags', 1)) : ?>
<?php echo JLayoutHelper::render('joomla.content.tags', $tagsData); ?>
<?php endif; ?>
<?php if ($params->get('show_description', 1) || $params->def('show_description_image', 1)) : ?>
<?php if ($beforeDisplayContent || $afterDisplayContent || $params->get('show_description', 1) || $params->def('show_description_image', 1)) : ?>
<div class="category-desc">
<?php if ($params->get('show_description_image') && $displayData->get('category')->getParams()->get('image')) : ?>
<img src="<?php echo $displayData->get('category')->getParams()->get('image'); ?>" alt="<?php echo htmlspecialchars($displayData->get('category')->getParams()->get('image_alt'), ENT_COMPAT, 'UTF-8'); ?>"/>
<?php endif; ?>
<?php echo $beforeDisplayContent; ?>
<?php if ($params->get('show_description') && $displayData->get('category')->description) : ?>
<?php echo JHtml::_('content.prepare', $displayData->get('category')->description, '', $extension .'.category.description'); ?>
<?php endif; ?>
<?php echo $afterDisplayContent; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,26 @@
// Note that this layout opens a div with the page class suffix. If you do not use the category children
// layout you need to close this div either by overriding this file or in your main layout.
$params = $displayData->params;
$category = $displayData->get('category');
$extension = $displayData->get('category')->extension;
$canEdit = $params->get('access-edit');
$className = substr($extension, 4);

$dispatcher = JEventDispatcher::getInstance();

$category->text = $category->description;
$dispatcher->trigger('onContentPrepare', array($extension . '.categories', &$category, &$params, 0));
$category->description = $category->text;

$results = $dispatcher->trigger('onContentAfterTitle', array($extension . '.categories', &$category, &$params, 0));
$afterDisplayTitle = trim(implode("\n", $results));

$results = $dispatcher->trigger('onContentBeforeDisplay', array($extension . '.categories', &$category, &$params, 0));
$beforeDisplayContent = trim(implode("\n", $results));

$results = $dispatcher->trigger('onContentAfterDisplay', array($extension . '.categories', &$category, &$params, 0));
$afterDisplayContent = trim(implode("\n", $results));

// This will work for the core components but not necessarily for other components
// that may have different pluralisation rules.
if (substr($className, -1) == 's')
Expand All @@ -35,17 +52,21 @@
<?php echo JHtml::_('content.prepare', $displayData->get('category')->title, '', $extension.'.category.title'); ?>
</h2>
<?php endif; ?>
<?php echo $afterDisplayTitle; ?>

<?php if ($params->get('show_tags', 1)) : ?>
<?php echo JLayoutHelper::render('joomla.content.tags', $tagsData); ?>
<?php endif; ?>
<?php if ($params->get('show_description', 1) || $params->def('show_description_image', 1)) : ?>
<?php if ($beforeDisplayContent || $afterDisplayContent || $params->get('show_description', 1) || $params->def('show_description_image', 1)) : ?>
<div class="category-desc">
<?php if ($params->get('show_description_image') && $displayData->get('category')->getParams()->get('image')) : ?>
<img src="<?php echo $displayData->get('category')->getParams()->get('image'); ?>"/>
<?php endif; ?>
<?php echo $beforeDisplayContent; ?>
<?php if ($params->get('show_description') && $displayData->get('category')->description) : ?>
<?php echo JHtml::_('content.prepare', $displayData->get('category')->description, '', $extension .'.category'); ?>
<?php endif; ?>
<?php echo $afterDisplayContent; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
Expand Down

0 comments on commit 463db7f

Please sign in to comment.