Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Optional content.prepare on text fields #44597

Open
wants to merge 2 commits into
base: 5.3-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions administrator/language/en-GB/plg_fields_text.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ PLG_FIELDS_TEXT="Fields - Text"
PLG_FIELDS_TEXT_LABEL="Text (%s)"
PLG_FIELDS_TEXT_PARAMS_FILTER_LABEL="Filter"
PLG_FIELDS_TEXT_PARAMS_MAXLENGTH_LABEL="Maximum Length (characters)"
PLG_FIELDS_TEXT_PARAMS_PREPARE_CONTENT_DESC="Optionally prepare the content with Joomla Content Plugins."
PLG_FIELDS_TEXT_PARAMS_PREPARE_CONTENT_LABEL="Prepare Content"
PLG_FIELDS_TEXT_XML_DESCRIPTION="This plugin lets you create new fields of type 'text' in any extensions where custom fields are supported."
13 changes: 13 additions & 0 deletions plugins/fields/text/params/text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@
label="PLG_FIELDS_TEXT_PARAMS_MAXLENGTH_LABEL"
filter="integer"
/>

<field
name="prepare_content"
type="list"
label="PLG_FIELDS_TEXT_PARAMS_PREPARE_CONTENT_LABEL"
description="PLG_FIELDS_TEXT_PARAMS_PREPARE_CONTENT_DESC"
filter="integer"
>
<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

</fieldset>
</fields>
</form>
14 changes: 14 additions & 0 deletions plugins/fields/text/text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@
label="PLG_FIELDS_TEXT_PARAMS_MAXLENGTH_LABEL"
filter="integer"
/>

<field
name="prepare_content"
type="radio"
layout="joomla.form.field.radio.switcher"
label="PLG_FIELDS_TEXT_PARAMS_PREPARE_CONTENT_LABEL"
description="PLG_FIELDS_TEXT_PARAMS_PREPARE_CONTENT_DESC"
default="0"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

</fieldset>
</fields>
</config>
Expand Down
8 changes: 8 additions & 0 deletions plugins/fields/text/tmpl/text.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;

$value = $field->value;

if ($value == '') {
Expand All @@ -20,4 +22,10 @@
$value = implode(', ', $value);
}

if ($fieldParams->get('prepare_content', 0)) {
$value = HTMLHelper::_('content.prepare', htmlentities($value));
echo $value;
brianteeman marked this conversation as resolved.
Show resolved Hide resolved
return;
}

echo htmlentities($value);