mirror of
https://github.com/processwire/processwire.git
synced 2025-08-08 07:47:00 +02:00
Fix issue processwire/processwire-issues#1895
This commit is contained in:
@@ -981,7 +981,8 @@ class WireTextTools extends Wire {
|
|||||||
* - `tagOpen` (string): The required opening tag character(s), default is '{'
|
* - `tagOpen` (string): The required opening tag character(s), default is '{'
|
||||||
* - `tagClose` (string): The optional closing tag character(s), default is '}'
|
* - `tagClose` (string): The optional closing tag character(s), default is '}'
|
||||||
* - `recursive` (bool): If replacement value contains tags, populate those too? (default=false)
|
* - `recursive` (bool): If replacement value contains tags, populate those too? (default=false)
|
||||||
* - `removeNullTags` (bool): If a tag resolves to a NULL, remove it? If false, tag will remain. (default=true)
|
* - `removeNullTags` (bool): If a tag resolves to a NULL (i.e. field not present), remove it? (default=true)
|
||||||
|
* - `removeEmptyTags` (bool): If a tag value resolves to blank string, false or NULL, remove it? (default=true) 3.0.237+
|
||||||
* - `entityEncode` (bool): Entity encode the values pulled from $vars? (default=false)
|
* - `entityEncode` (bool): Entity encode the values pulled from $vars? (default=false)
|
||||||
* - `entityDecode` (bool): Entity decode the values pulled from $vars? (default=false)
|
* - `entityDecode` (bool): Entity decode the values pulled from $vars? (default=false)
|
||||||
* - `allowMarkup` (bool): Allow markup to appear in populated variables? (default=true)
|
* - `allowMarkup` (bool): Allow markup to appear in populated variables? (default=true)
|
||||||
@@ -995,7 +996,8 @@ class WireTextTools extends Wire {
|
|||||||
'tagOpen' => '{', // opening tag (required)
|
'tagOpen' => '{', // opening tag (required)
|
||||||
'tagClose' => '}', // closing tag (optional)
|
'tagClose' => '}', // closing tag (optional)
|
||||||
'recursive' => false, // if replacement value contains tags, populate those too?
|
'recursive' => false, // if replacement value contains tags, populate those too?
|
||||||
'removeNullTags' => true, // if a tag value resolves to a NULL, remove it? If false, tag will be left in tact.
|
'removeNullTags' => true, // If a tag resolves to a NULL (i.e. field not present on page), remove it?
|
||||||
|
'removeEmptyTags' => true, // If a tag value resolves to blank string, false or null, remove it?
|
||||||
'entityEncode' => false, // entity encode values pulled from $vars?
|
'entityEncode' => false, // entity encode values pulled from $vars?
|
||||||
'entityDecode' => false, // entity decode values pulled from $vars?
|
'entityDecode' => false, // entity decode values pulled from $vars?
|
||||||
'allowMarkup' => true, // allow markup to appear in populated variables?
|
'allowMarkup' => true, // allow markup to appear in populated variables?
|
||||||
@@ -1015,6 +1017,7 @@ class WireTextTools extends Wire {
|
|||||||
if(is_object($vars)) {
|
if(is_object($vars)) {
|
||||||
if($vars instanceof Page) {
|
if($vars instanceof Page) {
|
||||||
$fieldValue = $options['allowMarkup'] ? $vars->getMarkup($fieldName) : $vars->getText($fieldName);
|
$fieldValue = $options['allowMarkup'] ? $vars->getMarkup($fieldName) : $vars->getText($fieldName);
|
||||||
|
if($fieldValue === '' && $vars->get($fieldName) === null) $fieldValue = null;
|
||||||
} else if($vars instanceof WireData) {
|
} else if($vars instanceof WireData) {
|
||||||
$fieldValue = $vars->get($fieldName);
|
$fieldValue = $vars->get($fieldName);
|
||||||
} else {
|
} else {
|
||||||
@@ -1024,6 +1027,9 @@ class WireTextTools extends Wire {
|
|||||||
$fieldValue = isset($vars[$fieldName]) ? $vars[$fieldName] : null;
|
$fieldValue = isset($vars[$fieldName]) ? $vars[$fieldName] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if value resolves to empty and we are not removing empty tags, then do not add to replacements
|
||||||
|
if(empty($fieldValue) && !strlen("$fieldValue") && !$options['removeEmptyTags']) continue;
|
||||||
|
|
||||||
// if value resolves to null and we are not removing null tags, then do not add to replacements
|
// if value resolves to null and we are not removing null tags, then do not add to replacements
|
||||||
if($fieldValue === null && !$options['removeNullTags']) continue;
|
if($fieldValue === null && !$options['removeNullTags']) continue;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user