Text Template Bundle

Categories
Add-ons
Akeneo PIM compatibilty
Versions:
Price: €750.00
Version:
3.0.0

Description

Overview

Do you use texts like the following in your product descriptions?

The HP HD 5210 is a Skype®-certified autofocus HD webcam that is available since September 19, 2011. It provides up to 1920 x 1080 widescreen streams at a frame rate of 30.

The above example contains four attributes that are part of the default Akeneo demo data:

  • Product name
  • Release date
  • Maximum video resolution
  • Maximum frame rate

Now guess what happens when you or a co-worker updates the frame rate attribute from 30 to 60?! Correct, the description would not reflect this change until you edit the text by hand. We all are humans and it's easy to forget to update the related texts for all scopes and locales after such a change.

Wouldn't it be nice if you could reference the different attributes directly in the description? That's exactly what this extension provides.

Features

  • Adds two new attribute types ("Twig Text" and "Twig Text Area") where you can define templates referencing any attribute value of the current product
  • Provides auto-completion for your attribute codes and custom filters
  • Works with and without WYSIWYG enabled
  • Supports "value per channel" and "value per locale" attributes
  • Supports reference data objects
  • Supports product models
  • Supports assigned categories and associations
  • Use provided Twig filters to format metrics, dates, currencies etc. or simply add your own
  • Use the product REST API or the default CSV/XLSX exports to access the rendered texts for your online shop etc.

Are you interested? Feel free to contact us.

Release notes

Release notes

Currently, this extension supports Akeneo 2.3 and 3.x.

Installation

Preliminaries

After purchasing this bundle, you'll get access to the private Git repository. We also assume that you are running Akeneo via Docker. If this is not the case, you can simply derive the installation steps.

Installation

After adding the repositories configuration to your composer.json file, run composer to install the files:

docker-compose exec fpm php -d memory_limit=3G /usr/local/bin/composer require mitting/akeneo-text-template-bundle v3.0.x-dev

Activate the bundle

Add the following in app/AppKernel.php to registerProjectBundles():

new Mitting\Bundle\AkeneoTextTemplateBundle\MittingAkeneoTextTemplateBundle(),

Append the routing configuration to app/config/routing.yml:

mitting_akeneo_text_template:
    resource: "@MittingAkeneoTextTemplateBundle/Resources/config/routing.yml"

Then run ./bin/docker/pim-front.sh to finish the installation.

Documentation

Documentation

The bundle adds the "Twig Text" and "Twig Text Area" attribute types. Simply create new attributes of the given types and optionally define a default template. Now you can write twig markup to print out your attribute in any format you like.

Template snippets

Slug including categories

Create a slug based on assigned categories and SKU.

{{ categories | merge([name, sku]) | join(' ') | slugify }}
pc-monitors-tvs-and-projectors-nec-nec-ex201w-10627329

Metric attribute

This example shows how the localizedmetric-filter prints out the value suffixed by the translated metric unit.

Weight: {{ weight | localizedmetric }}
Weight: 512 Gram

Calculate a value based on two metric attributes:

Productiveness: {{(v.amount / a.amount)|number_format}} {{v.symbol}}/{{a.symbol}}
Productiveness: 1.5 l/m²

Price attribute

The localizedprice-filter is based on the localizedcurrency-filter and makes it easy to print the given currency.

Price: {{price | localizedprice('EUR') }}
Price: €100.00

Date attribute

Twig already provides the localizeddate-filter. Here you can see how to use the locale-variable, which is automatically available.

Date: {{ date | localizeddate('medium', 'none', locale) }}
Date: Sep 19, 2011

Number attribute

Use the localizednumber-filter to format any numbers.

Number: {{ number | localizednumber('decimal', 'default', locale) }}
Number: 1.250.000

Boolean attribute

The if-statement lets you output any text.

Available: {% if available %}yes{% else %}no{% endif %}
Available: yes

Simple select attribute

Printing the localized value of a select attribute can be achieved by using the localized-filter.

Color: {{ color | localized }}
Color: Grey

Multi select attribute

Like in the previous simple select snipped, you can use the localized-filter to output multiple values, separated by comma.

Colors: {{ colors | localized }}
Colors: Grey, Red, Blue

Reference data attribute

You can output the result of __toString() like any other scalar attribute.

Color: {{ color_reference }}
Color: Red

Reference data attribute property

It's also possible, to output properties of a reference data object.

Hex-Code: {{ color_reference.hex }}
Hex-Code: #ff0000

Reference data attribute property translation

If your reference data object implements the TranslatableInterface interface, you can directly output the translation.

Pictogram: {{ pictogram.translation.label }}
Pictogram: flameable

Reference data attribute twig filter

Of cause you can register your own twig filters to output anything you want.

{{ color_reference | format_color }}
The hex-code of the color "Red" is #ff0000

Are you missing a feature?

There are plenty of possibilities. Feel free to ask us your questions.

List your extension on Akeneo Marketplace

Learn about the best practices to enrich Akeneo ecosystem.

Share your contributions with Akeneo Community any way you want.

Need help? Please read our
submission requirements and manual.