Keyword

customize item.php - translated extra field values

  • ATHANASIOS ILIOPOULOS
  • ATHANASIOS ILIOPOULOS's Avatar Topic Author
  • Offline
  • Senior Member
More
12 years 7 months ago - 12 years 7 months ago #65286 by ATHANASIOS ILIOPOULOS
customize item.php - translated extra field values was created by ATHANASIOS ILIOPOULOS
I hope somebody here can give an answer to my question.

I am using several custom k2 templates assigned to categories & corresponding extra field groups (data types lets say). My site is bilingual ... For example i have:

extra field group: efg1
custom k2 template: templ1
extra fields: ef1, ef2, ..., ef20

I have modified my item.php file in order only to show some (lets say: ef1, ef3, ef5, ef6) extra fields in the following way (item.php):
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
        <!-- Item extra fields -->
        <div class="itemExtraFields">
                <h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
                <ul>
                <?php
                $fields = OnDesign::GetFields($this->item->extra_fields, "Dinning Facilities,Accommodation Facilities,Other Facilities,Free Camping,Nudism,Related Routes & Paths,Regions,Location,Access - full information");
                ?>
                        <?php 
                        $cnt = 0;
                        foreach ($fields as $key => $value):?>
                        <li class="<?php echo ($cnt++ % 2) ? "odd" : "even"; ?>">
                                <span class="itemExtraFieldsLabel"><?php echo $key; ?>:</span>
                                <span class="itemExtraFieldsValue"><?php echo $value; ?></span>
                        </li>
                        <?php endforeach; ?>
                        </ul>
                <div class="clr"></div>
                </div>
                <?php endif; ?>


The code for Function OnDesign::GetFields is the following:
<?php
class OnDesign
{
        public static function GetFields($extraFields, $fieldsToGet)
        {
                $res = array();
                if (is_string($fieldsToGet))
                {
                        $fieldsToGet = explode(",", $fieldsToGet);
                        foreach($fieldsToGet as &$f)
                                $f = trim($f);
                }

                foreach($extraFields as $key => $extraField)
                {
                        if (in_array($extraField->name, $fieldsToGet))
                                $res[$extraField->name] = $extraField->value;
                }
                return $res;
        }
}

The PROBLEM is that if an extra field is translated through joomfish, the corresponding field label and value are not been populated.

a test page is shown here:





where the fields: nudism, and free camping are not populated (there are translated in greek) ...
Attachments:

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

  • ATHANASIOS ILIOPOULOS
  • ATHANASIOS ILIOPOULOS's Avatar Topic Author
  • Offline
  • Senior Member
More
12 years 7 months ago - 12 years 7 months ago #65287 by ATHANASIOS ILIOPOULOS
Replied by ATHANASIOS ILIOPOULOS on topic Re: customize item.php - translated extra field values
Anybody here with any ideas?

the code above works only if i keep the same label for translations (joomfish -> k2 extra fields -> label translation).

If i translate extra field label it can not fetch the extra fields

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

More
11 years 11 months ago #65288 by Peter Grube
Hi everyone,

I realize this is a fairly old topic but I am hoping someone maybe William may help me out with some information.

With the most recent K2 version it is now possible to place individual extra fields anywhere which is a most welcome feature. But as with anything there's always a downside you either have to code for every extra field or you get duplicates using the standard
Log in  or Create an account to join the conversation.