Add the lib to your composer.json, run composer require novactive/ezextrabundle
to refresh dependencies.
Then inject the bundle in the bundles.php
of your application.
Novactive\Bundle\eZExtraBundle\NovaeZExtraBundle::class => [ 'all'=> true ],
Activate the sroutes:
_novaezextraRoutes:
resource: "@NovaeZExtraBundle/Resources/config/routing/main.yml"
php app|ezpublish/console cache:clear --env=dev
Go to : /_novaezextra/dev/test
{% set content = eznova_parentcontent_by_contentinfo( content ) %}
Note : you get the content of the parent on the main location
{% set contentType = eznova_location_by_content( content ) %}
{% set content = eznova_relationlist_field_to_content_list( ez_field_value( content, 'internal_links' ) ) %}
Note : return an array of direct linked contents by the relation objects FieldType
{% set content = eznova_is_rich_text_really_empty( ez_field_value( content, 'description' ) ) %}
Note : returns true if the value of RichText field is empty excluding the tags, whitespaces and line breaks, false otherwise
{% set ctaField | ctaize %}
Note : Filter which converts the string like ezcontent://123 or ezlocation://234 to the URL of specified content or location
{% set richTextFieldValue | ezlinks %}
Note : Filter which fixes the mistakes in opening/closing div tags and converts string like ezlocation://234 to the URL of specified location
{% set stringValue | htmldecode %}
Note : Filter which applies html_entity_decode php function to the specified var
{{ get_image_tag(content, 'thumbnail', 'card_slider') }}
Generates the picture html code including images for original, retina and mobile screens specified in the image variations config like the following:
optimized_original:
reference: ~
filters:
- { name: auto_rotate }
- { name: strip }
- { name: geometry/scaledownonly, params: [ 200,200 ] }
optimized_original_retina:
reference: ~
filters:
- { name: auto_rotate }
- { name: strip }
- { name: geometry/scaledownonly, params: [ 400,400 ] }
optimized_original_mobile:
reference: ~
filters:
- { name: auto_rotate }
- { name: strip }
- { name: geometry/scaledownonly, params: [ 50,50 ] }
If the placeholder dimensions are specified with empty content and variation then the placeholder image will be displayed:
{{ get_image_tag(null, 'image', '', {placeholder: {width: 300, height: 100}}) }}
The same as previous but returning just an image URL instead of tag.
Returns the Content by the Image Asset field. Requires the eZ\Publish\API\Repository\Values\Content\Field to be specified.
IMPORTANT: The image placeholder is enabled by default but can be disabled by setting the bool value to _ENABLE_IMAGEPLACEHOLDER env variable.
{{ render( controller( "eZNovaExtraBundle:Picture:alias", { "contentId": content.getField('picture').value.destinationContentId, "fieldIdentifier": "image", "alias": "large" })) }}
The goal was to mimic the old Fetch Content List
public function contentTree( $parentLocationId, $typeIdentifiers = [], $sortClauses = [], $limit = null, $offset = 0, $additionnalCriterion );
public function contentList( $parentLocationId, $typeIdentifiers = [], $sortClauses = [], $limit = null, $offset = 0, $additionnalCriterion );
public function nextByAttribute( $locationId, $attributeIdentifier, $locale, $additionnalCriterions = [] );
public function nextByPriority( $locationId, $aditionnalCriterions = [] )
public function previousByAttribute( $locationId, $attributeIdentifier, $locale, $additionnalCriterion = [] )
public function previousByPriority( $locationId, $additionnalCriterion = [] )
public function getSelectionTextValue($content, $identifier)
Return an array of Result
Usage:
{% for child in children %}
<h2>{{ ez_field_value( child.content, "title" ) }}</h2>
{{ ez_render_field( child.content, "overview" ) }}
<a href="{{ path( "ez_urlalias", { "locationId" : child.content.contentInfo.mainLocationId } ) }}">{{ "Learn more" | trans() }}</a>
{% endfor %}
Simply inject the children ( and potentially other things on a view Full )
Add your provider in a folder of your bundle
Project\Bundle\GeneralBundle\ChildrenProvider\YOUCONTENTIDENTIFIERPROVIDERCLASS:
tags:
- { name: novactive.ezextra.children.provider, contentTypeIdentifier: YOUCONTENTIDENTIFIER }
You class YOUCONTENTIDENTIFIERPROVIDERCLASS must extend Novactive\Bundle\eZExtraBundle\EventListener\Type
After you need to create a method for each view you display if you want to get children in your template The goal is to have children on each view.
Ex:
namespace Yoochoose\Bundle\GeneralBundle\ChildrenProvider;
use Novactive\Bundle\eZExtraBundle\EventListener\Type;
use eZ\Publish\API\Repository\Values\Content\Query;
class PersonalizationEngine extends Type
{
//its also use as default to get the full view children
public function getChildren($viewParameters, SiteAccess $siteAccess = null)
{
return $this->contentHelper->contentList( $this->location->id, [ 'article' ], array( new Query\SortClause\Location\Priority( Query::SORT_ASC ) ), 10);
}
public function getLineChildren( $viewParameters )
{
...
}
}
public function loadReverseRelations(ContentInfo $contentInfo, int $offset = 0, int $limit = -1): RelationList
Returns the list of reverse relations (RelationList) of the specified ContentInfo
public function generateRouteLocation(Location $location): string
public function generateRouteContent(Content $content): string
public function generateRouteWrapper(Wrapper $wrapper): string
The trait that allows to get the Route by location, content or Wrapper object.
This allows you to specify different ez views for the same content type but with different values of particular field.
IMPORTANT: By default the field name is set to matcher but can be rewritten by specifying it in the _VIEW_MATCHER_FIELD_IDENTIFIER_ env variable.
Then for example if you set the business value to the field that is set to identify the view (matcher by default) inside the Article Content Type then another template can be defined for that using the following config:
article_business:
template: '@ezdesign/full/article_business.html.twig'
match:
Identifier\ContentType: [ 'article' ]
'@Novactive\Bundle\eZExtraBundle\Core\ViewMatcher\ContentTypeField': 'business'