diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 009ed1ed1..b3492a7ab 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -73,7 +73,7 @@ class Category extends BaseLoop Argument::createIntTypeArgument('parent'), Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('not_empty', 0), - Argument::createBooleanTypeArgument('visible', 1), + Argument::createBooleanOrBothTypeArgument('visible', 1), new Argument( 'order', new TypeCollection( @@ -122,7 +122,8 @@ class Category extends BaseLoop $search->filterById($exclude, Criteria::NOT_IN); } - $search->filterByVisible($this->getVisible() ? 1 : 0); + if ($this->getVisible() != '*') + $search->filterByVisible($this->getVisible() ? 1 : 0); $orders = $this->getOrder(); diff --git a/core/lib/Thelia/Type/BooleanOrBothType.php b/core/lib/Thelia/Type/BooleanOrBothType.php new file mode 100644 index 000000000..13c76e254 --- /dev/null +++ b/core/lib/Thelia/Type/BooleanOrBothType.php @@ -0,0 +1,53 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Type; + +/** + * This filter accepts either a boolean value, or '*' which means both, true and false + * + * @author Etienne Roudeix + * + */ + +class BooleanOrBothType implements TypeInterface +{ + + const ANY = '*'; + + public function getType() + { + return 'Boolean or both type'; + } + + public function isValid($value) + { + return $value === self::ANY || filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null; + } + + public function getFormattedValue($value) + { + if ($value === self::ANY) return $value; + + return $value === null ? null : filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); + } +}