- Posts: 4
COMMUNITY FORUM
Adding odd even classes to itemViewList & catItemBody
- DigiSol
- Topic Author
- Offline
- New Member
Less
More
2 years 1 month ago - 2 years 1 month ago #180396
by DigiSol
Adding odd even classes to itemViewList & catItemBody was created by DigiSol
Hello,
I'm working on a project that uses K2 and I would like to add odd-even classes to the itemViewList.
Below is the code that I use in category_item.phpAnd this is the code in category.php
Joomla version 3.10.11
K2 version 2.10.3
Thanks a lot.
I'm working on a project that uses K2 and I would like to add odd-even classes to the itemViewList.
Below is the code that I use in category_item.php
<div class="catItemBody">
<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?>
<div class="catItemImageBlock">
<div class="catItemImage">
<a href="<?php echo $this->item->link; ?>">
<img src="<?php echo $this->item->image; ?>" />
</a>
</div>
</div>
<?php endif; ?>
<?php if($this->item->params->get('catItemTitle')): ?>
<h3 class="catItemTitle">
<?php echo $this->item->title; ?>
</h3>
<?php endif; ?>
<?php if($this->item->params->get('catItemIntroText')): ?>
<div class="catItemIntroText">
<?php echo $this->item->introtext; ?>
</div>
<?php endif; ?>
<?php if ($this->item->params->get('catItemReadMore')): ?>
<div class="catItemReadMore">
<a class="k2ReadMore" href="<?php echo $this->item->link; ?>">
<button>
Περισσότερα
</button>
</a>
</div>
<?php endif; ?>
</div>
<?php
/**
* @version 2.10.x
* @package K2
* @author JoomlaWorks https://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2020 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
?>
<!-- Start K2 Category Layout -->
<div id="k2Container" class="itemListView services">
<?php if ((isset($this->leading) || isset($this->primary) || isset($this->secondary) || isset($this->links)) && (count($this->leading) || count($this->primary) || count($this->secondary) || count($this->links))): ?>
<!-- Item list -->
<div class="itemList">
<?php if (isset($this->leading) && count($this->leading)): ?>
<!-- Leading items -->
<div id="itemListLeading">
<?php foreach($this->leading as $key=>$item): ?>
<?php
// Define a CSS class for the last container on each row
if ((($key+1)%($this->params->get('num_leading_columns'))==0) || count($this->leading) < $this->params->get('num_leading_columns'))
$lastContainer= ' itemContainerLast';
else
$lastContainer='';
?>
<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->leading)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_leading_columns'), 1).'%;"'; ?>>
<?php
// Load category_item.php by default
$this->item = $item;
echo $this->loadTemplate('item');
?>
</div>
<?php if (($key+1)%($this->params->get('num_leading_columns'))==0): ?>
<div class="clr"></div>
<?php endif; ?>
<?php endforeach; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if (isset($this->primary) && count($this->primary)): ?>
<!-- Primary items -->
<div id="itemListPrimary">
<?php foreach($this->primary as $key=>$item): ?>
<?php
// Define a CSS class for the last container on each row
if ((($key+1)%($this->params->get('num_primary_columns'))==0) || count($this->primary) < $this->params->get('num_primary_columns'))
$lastContainer= ' itemContainerLast';
else
$lastContainer='';
?>
<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->primary)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_primary_columns'), 1).'%;"'; ?>>
<?php
// Load category_item.php by default
$this->item = $item;
echo $this->loadTemplate('item');
?>
</div>
<?php if (($key+1)%($this->params->get('num_primary_columns'))==0): ?>
<div class="clr"></div>
<?php endif; ?>
<?php endforeach; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if (isset($this->secondary) && count($this->secondary)): ?>
<!-- Secondary items -->
<div id="itemListSecondary">
<?php foreach($this->secondary as $key=>$item): ?>
<?php
// Define a CSS class for the last container on each row
if ((($key+1)%($this->params->get('num_secondary_columns'))==0) || count($this->secondary) < $this->params->get('num_secondary_columns'))
$lastContainer= ' itemContainerLast';
else
$lastContainer='';
?>
<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->secondary)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_secondary_columns'), 1).'%;"'; ?>>
<?php
// Load category_item.php by default
$this->item = $item;
echo $this->loadTemplate('item');
?>
</div>
<?php if (($key+1)%($this->params->get('num_secondary_columns'))==0): ?>
<div class="clr"></div>
<?php endif; ?>
<?php endforeach; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if (isset($this->links) && count($this->links)): ?>
<!-- Link items -->
<div id="itemListLinks">
<h4><?php echo JText::_('K2_MORE'); ?></h4>
<?php foreach($this->links as $key=>$item): ?>
<?php
// Define a CSS class for the last container on each row
if ((($key+1)%($this->params->get('num_links_columns'))==0) || count($this->links) < $this->params->get('num_links_columns'))
$lastContainer= ' itemContainerLast';
else
$lastContainer='';
?>
<div class="itemContainer<?php echo $lastContainer; ?>"<?php echo (count($this->links)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('num_links_columns'), 1).'%;"'; ?>>
<?php
// Load category_item.php by default
$this->item = $item;
echo $this->loadTemplate('item');
?>
</div>
<?php if (($key+1)%($this->params->get('num_links_columns'))==0): ?>
<div class="clr"></div>
<?php endif; ?>
<?php endforeach; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
</div>
<!-- Pagination -->
<?php if ($this->pagination->getPagesLinks()): ?>
<div class="k2Pagination">
<?php if ($this->params->get('catPagination', 1)): ?>
<div class="k2PaginationLinks">
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
<?php endif; ?>
<?php if ($this->params->get('catPaginationResults', 1)): ?>
<div class="k2PaginationCounter">
<?php echo $this->pagination->getPagesCounter(); ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<!-- End K2 Category Layout -->
Joomla version 3.10.11
K2 version 2.10.3
Thanks a lot.
Last edit: 2 years 1 month ago by DigiSol.
Please Log in or Create an account to join the conversation.