Keyword

K2 extra fields dans un site multi-langue

  • Anne Perroud
  • Anne Perroud's Avatar Topic Author
  • Offline
  • New Member
More
1 week 4 days ago #170816 by Anne Perroud
Anne Perroud created the topic: K2 extra fields dans un site multi-langue
J'ai un site en 3 langues, avec K2 et des extra-fields.
J'aimerais que les libellés des champs additionnels apparaissent dans la bonne langue.
Par exemple, j'ai un champ intitulé Type de publication, avec les valeurs suivantes

Argument
Article publié
Chapitre de livre
Conférence
Discours d'ouverture
Discours de fermeture
Intervention
Livre
Note de lecture
Publication électronique
Synthèse
Texte préparatoire
Thèse
J'aimerais que dans la version italienne le nom du champ et les valeurs apparaissent en italien.
Est-ce possible sans installer Falang ?
Merci de votre réponse.

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

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
1 week 4 days ago #170823 by Fotis
Fotis replied the topic: K2 extra fields dans un site multi-langue
K2 extra fields don't support translating content to other languages at the moment.

There is a trick though you can do.

Create a different set of extra fields for each language. One for each language.

When you assign all these items into an extra field group, they will get loaded in the K2 item form (whose content CAN be translated and assigned to different languages). Then, all you have to do is simply fill in the extra fields of the respective language. E.g. if you're writing the Italian content, fill in the extra fields with Italian labels on them, not the French ones.

Finally, modify the foreach loop where extra fields are rendered, in order to hide empty values. So in item.php, change this (around line 253):
                <?php foreach ($this->item->extra_fields as $key => $extraField): ?>
                <?php if($extraField->value != ''): ?>
                <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?> alias<?php echo ucfirst($extraField->alias); ?>">
                    <?php if($extraField->type == 'header'): ?>
                    <h4 class="itemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
                    <?php else: ?>
                    <span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
                    <span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
                    <?php endif; ?>
                </li>
                <?php endif; ?>
                <?php endforeach; ?>

to this:
                <?php foreach ($this->item->extra_fields as $key => $extraField): ?>
                <?php if($extraField->value != ''): ?>
                <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?> alias<?php echo ucfirst($extraField->alias); ?>">
                    <?php if($extraField->type == 'header'): ?>
                    <h4 class="itemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
                    <?php else: ?>
                    <?php if (!empty(trim($extraField->value))): /* Show extra fields with values only! */ ?>
                    <span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
                    <span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
                    <?php endif; ?>
                    <?php endif; ?>
                </li>
                <?php endif; ?>
                <?php endforeach; ?>

Done.


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

  • Anne Perroud
  • Anne Perroud's Avatar Topic Author
  • Offline
  • New Member
More
1 week 3 days ago - 1 week 3 days ago #170831 by Anne Perroud
Anne Perroud replied the topic: K2 extra fields dans un site multi-langue
This does not reply to my needs, but thanks for your quick answer.
Last Edit: 1 week 3 days ago by Anne Perroud.

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

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
1 week 3 days ago #170836 by Fotis
Fotis replied the topic: K2 extra fields dans un site multi-langue
Of course it does. Different set of extra fields for each language. Can't get any simpler. These are static data either way.


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

Moderators: william whiteJiliko.net