unrealmanu / ez-content-field-filter
Filter field of ez Content
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:ezplatform-bundle
Requires
- php: ^7.2
- ezsystems/ezplatform-ee: ^2.5
- symfony/framework-bundle: ~3.0|~4.0|~5.0
This package is auto-updated.
Last update: 2025-02-22 02:38:57 UTC
README
Filter "Content Class -Fields-" with specific value type instance
Instructions
Create new Filters().
$fieldHelper = new Filters();
Set the Content need to filter fields
- support only "eZ\Publish\API\Repository\Values\Content\Content"
- Single $content or Array [$content, $content, $content]
$fieldHelper->setContent($content);
Choose the filter "value class" instance
- Choose single or multiple instance of class for filtering the content
use eZ\Publish\Core\FieldType\Image\Value as ImageValue;
use eZ\Publish\Core\FieldType\RichText\Value as RichTextValue;
use eZ\Publish\Core\FieldType\TextBlock\Value as TextBlockValue;
use eZ\Publish\Core\FieldType\TextLine\Value as TextLineValue;
- Single Value::class or [ValueA::class, ValueB::class, ValueC::class]
$fieldHelper->setClass(ImageValue::class);
- Field name from get value (Required)
$fieldHelper->setValueField('uri');
Example
use unrealmanu\ezFieldIterator\Filters as FieldHelper;
/**
* @return string|null
*/
function myFilter():?string
{
$fieldHelper = new FieldHelper();
$fieldHelper->setContent($content);
$fieldHelper->setClass(ImageValue::class);
$fieldHelper->setValueField('uri');
return $fieldHelper->getFirstChildren();
//return $fieldHelper->getChildren();
}
Real World application
- Get all images of "contents array" for image-sitemap
- Get first image/text of "contents array" for search-indexing
- Get all text field of Content for generate list of Tag/Description etc
- Use your creativity :)