eZ templating – Override an embed image template

16 Sep

eZ 5 allows to override embed templates as well. Right now it is hard to find out which data is passed to the template.

In order to override the template the template has to be configured in your yml file:

content_view:
    embed:
        imageEmbedRuleset:
            template: WebsiteBundle:block/content:image.html.twig
            match:
                Identifier\ContentType: [image]

In this case for ContentTypes of type image your template will be used

Place a template in your Resources/view folder (in this example Resources/views/block/content/image.html.twig is used):

{% if not ez_is_field_empty( content, 'image' ) %}
 
   {{ ez_render_field( content, 'image',
     { parameters: {
       alias: objectParameters.size|default( 'original' ),
       showFigure: false,
       align: objectParameters.align|default( 'center' )
      } }
     )
}}
{% endif %}

eZ passes a lot of parameters to the embed template:

embed-object_tpl-parameters

  • objectParameters.size: imageAlias used in the backend
  • content: your object which has been embedded
  • linkParameters: if a link has been set in the editor

eZ trouble shooting: Login into the new stack from the legacy stack

24 Aug

eZ Systems changed the way how logins are handled a few versions ago (versions > 5.3).

If your application still uses the legacy stack and you are using your own login module in the old stack you might have a problem: the new eZ (and Symfony) version will not login the user on the Symfony stack.

If you want to login a user in the new stack as well as in the legacy stack this solution in eZ 4 might help:

 $userId =  = 1224;
 $container = ezpKernel::instance()->getServiceContainer();
 try {
      
     $repository = $container->get('ezpublish.api.repository');
     $userService = $repository->getUserService();
     $ezUser = $userService->loadUser($userId);
     if ($ezUser) {
            $user = new CoreUser($ezUser);
            $providerKey = 'ezpublish_front';
            $token = new UsernamePasswordToken($user, null, $providerKey);

            $securityContextService = $container->get('security.context');
            $securityContextService->setToken($token);

            $repository->setCurrentUser($ezUser);
    } else {
            eZDebug::writeError('User with id '.$userId.' in new stack not found, login falied',__METHOD__);
    }
} catch (\Exception $e) {
     eZDebug::writeError("Exception while trying to login on new stack: ". $e->getMessage());
 }

eZ Publish 5: Custom tags with Symfony services

13 Feb

How to render a custom tag for XML Text using your Symfony services and templates

One of my favorite features of eZ Publish is the ability to create nice-looking content with various nicely formatted blocks. That makes reading more interesting for the user. Due to storing content as XML it is possible to present information however you want. Along with a big number of standard tags like paragraph, image or table you are free to create your own custom tags: an embedded YouTube video, Google Maps, a sllideshare presentation, a source code block with syntax highlighting, QR-code etc. This article will show you how to use Symfony services to render custom tags.

Continue reading “eZ Publish 5: Custom tags with Symfony services” »

Technical debt in PHP projects

21 Nov

Analyse der technischen Schulden von PHP Projekten – eZ Publish 5 kann punkten

Was sind technische Schulden in der Software Entwicklung? Dabei handelt es sich um eine in neuerer Zeit eingeführte Metapher für die möglichen Konsequenzen schlechten Software Designs und schlechter technischer Umsetzung von Software. Man versteht darunter gemeinhin, wie viel zusätzlichen Aufwand man für Änderungen und Erweiterungen einplanen muss, im Vergleich zu gut designter und geschriebener Software. Mehr zum Thema Technische Schuld oder Technische Schulden (engl. technical debt) kann man bei Wikipedia nachlesen.

Continue reading “Technical debt in PHP projects” »

Extend eZ 5.3 – Change user authentication to login with email

11 Jul

Sometimes it is required that a user needs to be logged in additionally via email address, not only via username. In eZ Publish prior to version 5.3 this was possible since eZ provided legacy settings (site.ini) for it:

[UserSettings]
AuthenticateMatch=login;email

Starting with eZ 5.3 the logic has been changed and eZ Publish is now using the security feature of Symfony. This means a login with the email address isn´t possible anymore and eZ will use the login only.  The new version seems to ignore the settings defined in „AuthenticateMatch“.

If you want to allow this functionality, there are two things that you need to do:

Continue reading “Extend eZ 5.3 – Change user authentication to login with email” »

Operator in PHP nutzen

3 Mai
Reproduktion in: Mix & Genest (Hsg.), 75 Jahre Mix & Genest, 1879-1954, E.Klett Stuttgart, o.J.

Reproduktion in: Mix & Genest (Hsg.), 75 Jahre Mix & Genest, 1879-1954, E.Klett Stuttgart, o.J.

Was würden wir nur ohne einen „Operator“ machen? Ohne dieses kleine Hilfsmittel würde wahrscheinlich keine eZ Publish Seite funktionieren. Wahrscheinlich? Nein, ganz sicher nicht. Oft werden sie nur in Templates benutzt, ob jetzt Twig oder eZ Template. Doch was ist, wenn man auf einen Operator auch mal über PHP zugreifen möchte?

Continue reading “Operator in PHP nutzen” »