Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • yellowjersey Friend
    #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!


    1. Screen-Shot-2013-10-30-at-12.04.07-AM
    phong nam Friend
    #510836

    Hi 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; ?>

    yellowjersey Friend
    #510987

    Thank 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!

Viewing 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