Keyword

Different CSS class for category layout grids

More
1 month 2 weeks ago - 1 month 2 weeks ago #180453 by Okan
I am so sorry if someone asked before but i coldn't find in the form.
So,
I want to use different css class in category_item.php file for each layout grid.
First tried to call each grid in the file like this but didn't work. It gives blank page.
<?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))) : ?>
<?php if (isset($this->links) && count($this->links)) : ?>
<!-- links items here -->
<?php else : ?>
<!-- rest items here -->
<?php endif; ?>
<?php endif; ?>

Than i tried to copy category_item.php and name it category_item-2.php and than applied this code in to category.php under the link's grid part.
Deleted this part
<?php // Load category_item.php by default
$this->item = $item;
echo $this->loadTemplate('item'); ?>

than added this
<?php // Load category_item.php by default
$this->item = $item;
echo include 'category_item-2.php'; ?>

It works fine but gives weird character in the its div.
imgur.com/a/SuifPqd
I coldn't find the reason from where those "1" is coming.

I hope someone can help me.

Regards
Last edit: 1 month 2 weeks ago by Okan.

Please Log in or Create an account to join the conversation.

More
1 month 1 week ago #180462 by Okan
Ok. I found solution and did this.
Delete this part
<?php
// Load category_item.php by default
$this->item = $item;
echo $this->loadTemplate('item');
?>

Than made it like this
<?php $this->item = $item; ?>
<?php K2HelperUtilities::setDefaultImage($this->item, 'itemlist', $this->params); ?>
<div class="col p-3">
<a class="d-block" href="<?php echo $this->item->link; ?>" title="<?php echo $this->item->title; ?>">
<img class="img-fluid w-100" src="<?php echo $this->item->image; ?>" alt="<?php if (!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption);
else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" />
</a>
<a class="d-block text-decoration-none fw-bold link-dark" href="<?php echo $this->item->link; ?>" title="<?php echo $this->item->title; ?>"><?php echo $this->item->title; ?></a>
</div>
Used bootstrap 5 classes

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum