Skip to content

Instantly share code, notes, and snippets.

@hans2103
Created July 24, 2013 09:42
Show Gist options
  • Save hans2103/6069260 to your computer and use it in GitHub Desktop.
Save hans2103/6069260 to your computer and use it in GitHub Desktop.
Joomla layout override for menu item type = Category Blog. I'm using com_content as an event calendar showing the items grouped by month and by day. It's a copy from blog.php and on line 47 the override starts. A new array has been created to be able to group the items. (Thanks to @yireo for helping me with the creation of the new array) Using t…
<?php
/**
* @package Joomla.Site
* @subpackage com_content
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// no direct access
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
?>
<div class="blog<?php echo $this->pageclass_sfx;?>">
<?php if ($this->params->get('show_page_heading')) : ?>
<h1>
<?php echo $this->escape($this->params->get('page_heading')); ?>
</h1>
<?php endif; ?>
<?php if ($this->params->get('show_category_title', 1) or $this->params->get('page_subheading')) : ?>
<h2>
<?php echo $this->escape($this->params->get('page_subheading')); ?>
<?php if ($this->params->get('show_category_title')) : ?>
<span class="subheading-category"><?php echo $this->category->title;?></span>
<?php endif; ?>
</h2>
<?php endif; ?>
<?php if ($this->params->get('show_description', 1) || $this->params->def('show_description_image', 1)) : ?>
<div class="category-desc">
<?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 echo JHtml::_('content.prepare', $this->category->description, '', 'com_content.category'); ?>
<?php endif; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php
$introcount=(count($this->intro_items));
$counter=0;
$introItems = array();
foreach($this->intro_items as $key => &$item) {
$item_yearmonth = JHTML::_('date', $item->created, JText::_('F Y'));
if(array_key_exists($item_yearmonth, $introItems) == false) {
$introItems[$item_yearmonth] = array();
}
$item_date = $item->created;
if(array_key_exists($item_date, $introItems[$item_yearmonth]) == false) {
$introItems[$item_yearmonth][$item_date] = array();
}
$introItems[$item_yearmonth][$item_date][] = $item;
}
?>
<?php if (!empty($introItems)) : ?>
<?php foreach ($introItems as $item_yearmonth_label => $item_days) : ?>
<h2><?php echo $item_yearmonth_label; ?></h2>
<?php foreach($item_days as $item_day_label => $item_day): ?>
<dl class="dl-horizontal">
<dt><?php echo JHTML::_('date', $item_day_label, JText::_('D d')); ?></dt>
<dd><ul>
<?php foreach($item_day as $item): ?>
<li><p>
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid)); ?>" title="<?php echo $this->escape($item->title); ?>"><?php echo $this->escape($item->title); ?></a> <span class="label"><?php echo $this->escape($item->category_title); ?></span><br/>
<?php echo strip_tags($item->introtext); ?>
</p></li>
<?php endforeach; ?>
</ul></dd>
<?php endforeach; ?>
</dl>
<?php endforeach; ?>
<?php endif; ?>
<?php if (($this->params->def('show_pagination', 1) == 1 || ($this->params->get('show_pagination') == 2)) && ($this->pagination->get('pages.total') > 1)) : ?>
<div class="pagination">
<?php if ($this->params->def('show_pagination_results', 1)) : ?>
<p class="counter">
<?php echo $this->pagination->getPagesCounter(); ?>
</p>
<?php endif; ?>
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
<?php endif; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment