-
AuthorPosts
-
October 30, 2013 at 5:11 am #191823
Hello,
The JA-Fubix Quickstart K2 home page includes a K2 Content module that displays the article category with a background color. The background color is defined by Extra Fields in K2, and is called by the ja-fubix/html/mod_k2_content/defaul.php file.
I want display the same category background color on the K2 item. Can someone tell me what code to add to the item.php to achieve this?
Thanks!
phong nam Friendphong nam
- Join date:
- May 2015
- Posts:
- 3779
- Downloads:
- 1
- Uploads:
- 587
- Thanks:
- 499
- Thanked:
- 974 times in 888 posts
November 1, 2013 at 3:57 am #510836Hi yellowjersey,
It will require quite much support time of to customize the K2 item layout (item.php) to reach your requirement because our developers just override the K2 content module layout to make the category name hightlighted on JA Fubix template. So, i suggest you to work with an experienced developer to help you handling this customization task.
The idea is that you can compare the extra field parameters of K2 item that our developer defined inside the K2 content module layout in templatesja_fubixhtmlmod_k2_contenttrendingdefault.php, at lines:
<?php if(count($items)): ?>
<?php
require_once (JPATH_ADMINISTRATOR. '/components/com_k2/models/extrafield.php');
$extraFieldModel = new K2ModelExtraField;
JTable::addIncludePath(JPATH_ADMINISTRATOR. '/components/com_k2/tables');
$category = JTable::getInstance('K2Category', 'Table');
?><ul>
<?php foreach ($items as $key=>$item) : ?>
<?php$category->load($item->categoryid);
$extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup);
$exclass = '';
if (count($extraFields)){
foreach ($extraFields as $extraField){
$defaultValues = json_decode($extraField->value);foreach ($defaultValues as $value){
if(strpos($value->value, 'tbg') === 0){
$exclass = ' ' . JApplication::stringURLSafe($value->value);
break;
}
}
}
}
?>
The category name in this module is defined at:
<?php if($params->get('itemCategory')): ?>
<a class="moduleItemCategory category-name <?php echo JApplication::stringURLSafe($item->categoryname), $exclass ?>" href="<?php echo $item->categoryLink; ?>"><?php echo $item->categoryname; ?></a>
<?php endif; ?>November 2, 2013 at 8:09 am #510987Thank you Leo. I’ll play with the code a bit, or try to repurpose the K2 content module to accomplish what I need.
Thanks again!
AuthorPostsViewing 3 posts - 1 through 3 (of 3 total)This topic contains 3 replies, has 2 voices, and was last updated by yellowjersey 11 years ago.
We moved to new unified forum. Please post all new support queries in our New Forum
K2 Content Module Category Background Color
Viewing 3 posts - 1 through 3 (of 3 total)