0
Welcome Guest! Login
0 items Join Now

hiding empty K2 extra fields

    • Tomek's Avatar
    • Tomek
    • Newbie
    • Posts: 2
    • Thanks: 0

    hiding empty K2 extra fields

    Posted 15 years 3 months ago
    • Hello
      Sorry if this is not the right place for asking. I know that K2 is JW extension but I'd like to use it with RT template.
      I am trying to hide empty extra fiellds in KS item viev. I found the hack of components/com_k2/templates/default/item.php file - section extra files. It works (hides empty extra fields) but breaks K@ item view (clears other elements of the viev also leaving only main picture and title). I think that there is a bug in the code Could sobebody please check the code below?
      <div class="itemExtraFields">
                      <h3><?php echo JText::_('Additional Info'); ?></h3>
                      <ul>
                              <?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
                              <?php
                              $emptyValue = false;
                              switch ($extraField->type) {
                                      case "textfield":
                                      case "textarea":
                                              if ($extraField->value =="") $emptyValue = true;
                                      break;
                                      case "link":
                                              if (strpos($extraField->value,"\"http://\"")) $emptyValue = true;
                                      break;
                                      case "radio":
                                      break;
                                      case "multipleSelect":
                                              // Test already done by K2. If value is empty, this type of field does not appear.
                                      break;
                                      case "select":
                                              // This type of field can't have an empty value (first item select by default)
                                      break;
                              }
                              ?>
                              <?php if (!$emptyValue): ?>
                              <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
                                      <span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
                                      <span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
                                      <br class="clr" />
                              </li>
                              <?php endif; ?>
                              <?php endforeach; ?>
                              </ul>
                  <div class="clr"></div>
                </div>

      Regards Tomasz
    • Tomek's Avatar
    • Tomek
    • Newbie
    • Posts: 2
    • Thanks: 0

    Re: hiding empty K2 extra fields

    Posted 15 years 3 months ago
    • OK I just found it. The code is OK but the place of inserting wasn't OK

Time to create page: 0.061 seconds