No need to apologize for Peter's tone...
Looking at the code of his plugin, although it's a system plugin, it basically executes in "content" events. K2 outputs the extra fields as separate data objects and the plugin events that his plugin uses can't access these data objects. That is not a K2 limitation.
If the plugin can't parse emails on the page's output (which would differentiate it from Joomla's built in cloaking plugin), then you can perform a simple override in how extra fields are rendered inside item.php.
If you don't use overrides already for K2, have a look at this:
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
If you already have an item.php override in place for the "item" view, then simply change your extra fields loop from the default:
<?php if($this->item->params->get('itemExtraFields') && isset($this->item->extra_fields) && count($this->item->extra_fields)): ?>
<!-- Item extra fields -->
<div class="itemExtraFields">
<h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
<ul>
<?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; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>
to (behold the huge changes required to cloak an email):
<?php if($this->item->params->get('itemExtraFields') && isset($this->item->extra_fields) && count($this->item->extra_fields)): ?>
<!-- Item extra fields -->
<div class="itemExtraFields">
<h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
<ul>
<?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>
<?php if($extraField->type == 'textfield'): ?>
<?php
// if the extra field type is "textfield" and the value of it validates as an email address,
// then process the field value to a cloaked email link
if (filter_var($extraField->value, FILTER_VALIDATE_EMAIL)) {
echo JHtml::_('email.cloak', $extraField->value);
}
?>
<?php else: ?>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<?php endif; ?>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
<?php endif; ?>
We built K2 to make sense, not to make people's lives harder.
Edited 7 years 6 months ago by JoomlaWorks