Last active
August 29, 2015 14:26
-
-
Save hans2103/745b65c83574cd86b5b5 to your computer and use it in GitHub Desktop.
Joomla! Category Blog - Agenda - template override
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This Gist is to show you how I made the agenda view on http://oeteldonk.org/agenda | |
It's a template override on the com_content category blog view. | |
No third party extensions. Only Joomla! with a template override | |
COPY | |
components/com_content/views/category/tmpl/blog.xml | |
TO | |
templates/<your-template>/html/com_content/category/agenda.xml | |
COPY | |
components/com_content/views/category/tmpl/blog.php | |
TO | |
templates/<your-template>/html/com_content/category/agenda.php | |
OPEN | |
templates/<your-template>/html/com_content/category/agenda.xml | |
FIND | |
COM_CONTENT_CATEGORY_VIEW_BLOG_TITLE | |
CHANGE BY | |
COM_CONTENT_CATEGORY_VIEW_AGENDA_TITLE | |
FIND | |
COM_CONTENT_CATEGORY_VIEW_BLOG_OPTION | |
CHANGE BY | |
COM_CONTENT_CATEGORY_VIEW_AGENDA_OPTION | |
FIND | |
TPL_JOOSTRAP_COM_CONTENT_CATEGORY_VIEW_BLOG_DESC | |
CHANGE BY | |
TPL_JOOSTRAP_COM_CONTENT_CATEGORY_VIEW_AGENDA_DESC | |
FIND | |
<field name="layout_type" | |
type="hidden" | |
default="blog" | |
/> | |
CHANGE BY | |
<field name="layout_type" | |
type="hidden" | |
default="agenda" | |
/> | |
SAVE & CLOSE | |
GOTO | |
Joomla! backend > Extensions > Language Manager | |
ADD new administrator language strings | |
COM_CONTENT_CATEGORY_VIEW_AGENDA_TITLE | |
= Category blog - agenda | |
COM_CONTENT_CATEGORY_VIEW_AGENDA_OPTION | |
= Blog - agenda | |
TPL_JOOSTRAP_COM_CONTENT_CATEGORY_VIEW_AGENDA_DESC | |
= Display agenda item in single column. | |
Now you can create a menu item using type Articles > Category blog - agenda. | |
Set leading articles and links to 0 (options tab) and assign the menu to a category. | |
Go to the newly created url and notice an error. The override on blog.php to agenda.php is not finished yet and Joomla! is trying to find agenda_children.php, agenda_item.php and agenda_leading.php. | |
Non of them will return after the override is done. | |
OPEN | |
templates/<your-template>/html/com_content/category/agenda.php | |
FIND & DELETE | |
<?php $leadingcount = 0; ?> | |
<?php if (!empty($this->lead_items)) : ?> | |
<div class="items-leading clearfix"> | |
<?php foreach ($this->lead_items as &$item) : ?> | |
<div class="leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>" | |
itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting"> | |
<?php | |
$this->item = & $item; | |
echo $this->loadTemplate('item'); | |
?> | |
</div> | |
<?php $leadingcount++; ?> | |
<?php endforeach; ?> | |
</div><!-- end items-leading --> | |
<?php endif; ?> | |
FIND & DELETE | |
<?php if (!empty($this->intro_items)) : ?> | |
<?php foreach ($this->intro_items as $key => &$item) : ?> | |
<?php $rowcount = ((int) $key % (int) $this->columns) + 1; ?> | |
<?php if ($rowcount == 1) : ?> | |
<?php $row = $counter / $this->columns; ?> | |
<div class="items-row cols-<?php echo (int) $this->columns; ?> <?php echo 'row-' . $row; ?> row-fluid clearfix"> | |
<?php endif; ?> | |
<div class="span<?php echo round((12 / $this->columns)); ?>"> | |
<div class="item column-<?php echo $rowcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>" | |
itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting"> | |
<?php | |
$this->item = & $item; | |
echo $this->loadTemplate('item'); | |
?> | |
</div> | |
<!-- end item --> | |
<?php $counter++; ?> | |
</div><!-- end span --> | |
<?php if (($rowcount == $this->columns) or ($counter == $introcount)) : ?> | |
</div><!-- end row --> | |
<?php endif; ?> | |
<?php endforeach; ?> | |
<?php endif; ?> | |
FIND & DELETE | |
<?php if (!empty($this->link_items)) : ?> | |
<div class="items-more"> | |
<?php echo $this->loadTemplate('links'); ?> | |
</div> | |
<?php endif; ?> | |
FIND & DELETE | |
<?php if (!empty($this->children[$this->category->id]) && $this->maxLevel != 0) : ?> | |
<div class="cat-children"> | |
<?php if ($this->params->get('show_category_heading_title_text', 1) == 1) : ?> | |
<h3> <?php echo JTEXT::_('JGLOBAL_SUBCATEGORIES'); ?> </h3> | |
<?php endif; ?> | |
<?php echo $this->loadTemplate('children'); ?> </div> | |
<?php endif; ?> | |
FIND | |
<?php | |
$introcount = (count($this->intro_items)); | |
$counter = 0; | |
?> | |
ADD AFTER | |
<?php | |
$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)) : ?> | |
<div class="page-content"> | |
<?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 class="catimg-<?php echo strtolower(preg_replace('/\s*/', '', $this->escape($item->category_title))); ?>"> | |
<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><br/> | |
<?php echo strip_tags($item->introtext); ?> | |
</li> | |
<?php endforeach; ?> | |
</ul> | |
</dd> | |
</dl> | |
<?php endforeach; ?> | |
<?php endforeach; ?> | |
</div> | |
<?php endif; ?> | |
SAVE&CLOSE | |
Every item is accompanied with an image. This image depends on the category alias the item belongs to. | |
The category structure for this site (http://oeteldonk.org/agenda) is: | |
Agenda | |
- Oeteldonk | |
- Clubkes | |
- Jeugdzaken | |
The css for these icons: | |
[class^="catimg-"], | |
[class*=" catimg-"]{ | |
display:block; | |
vertical-align:text-top; | |
background-image:url('../images/sprite-catimg.png'); | |
background-position:0 0; | |
background-repeat:no-repeat; | |
margin-top:1px; | |
padding-left:45px | |
} | |
.catimg-oeteldonk{background-position:0 0} | |
.catimg-jeugdzaken, | |
.catimg-dekoekerellen{background-position:0 -240px} | |
.catimg-clubkes{background-position:0 -120px} | |
The image is a sprite to reduce the amount of http-requests. | |
[url]http://oeteldonk.org/templates/joostrap/images/sprite-catimg.png[/url] | |
Guidelines for authors. | |
- use "Created Date" to indicate the day of the agenda item | |
- use "Start Publishing" to be define when the agenda item should be published. | |
- use "Finish Publishing" and set it to the day after create date to automatically disappear the agenda item the day after the event. | |
And now you have an agenda just like: http://oeteldonk.org/agenda |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment