General

  eZ Systems Website
  Editor documentation


  Developer documentation

  Back to the top

Skip to end of metadata
Go to start of metadata

Getting the code

The code created in this tutorial is available on GitHub: https://github.com/ezsystems/TweetFieldTypeBundle.

This tutorial covers the creation and development of a custom eZ Platform Field Type.

Field Types are the smallest building blocks of content. eZ Platform comes with about 30 native types that cover most common needs (Text line, Rich text, Email, Author list, Content relation, Map location, Float, etc.)

Field Types are responsible for:

  • Storing data, either using the native storage engine mechanisms or specific means

  • Validating input data

  • Making the data searchable (if applicable)

  • Displaying Fields of this type

Custom Field Types are a very powerful type of extension, since they allow you to hook deep into the content model.

You can find the in-depth documentation about Field Types and their best practices here. It describes how each component of a Field Type interacts with the various layers of the system, and how to implement those.

Intended audience

This tutorial is aimed at developers who are familiar with eZ Platform and are comfortable with operating in PHP and Symfony2.

Content of the tutorial

This tutorial will demonstrate how to create a Field Type on the example of a Tweet Field Type. It will:

  • Accept as input the URL of a tweet (https://twitter.com/<username>/status/<id>)

  • Fetch the tweet using the Twitter oEmbed API (https://dev.twitter.com/docs/embedded-tweets)

  • Store the tweet’s embed contents and URL

  • Display the tweet's embedded version when displaying the field from a template

 

Preparation

To start the tutorial, you need to make a clean eZ Platform installation. Follow the guide for your system from Step 1: Installation. Remember to install using the dev environment.

 

Start the tutorial

Steps

The tutorial will lead you through the following steps:

1. The bundle

2. API

This part covers the implementation of the eZ Platform API elements required to implement a custom Field Type.
Read more about implementing the Tweet\Value class and the Tweet\Type class.

3. Converter

Storing data from any Field Type in the Legacy Storage Engine requires that your custom data is mapped to the data model.
Read more about implementing the Legacy Storage Engine Converter.

4. Templating

Displaying a Field Type's data is done through a Twig template.
Read more about implementing the Field Type template.

5. PlatformUI integration

Viewing and editing values of the Field Type in PlatformUI requires that you extend PlatformUI, using mostly JavaScript.

You should ideally read the general extensibility documentation for PlatformUI. You can find information about view templates in the next tutorial. Edit templates are not documented at the time of writing, but Netgen has published a tutorial that covers the topic: http://www.netgenlabs.com/Blog/Adding-support-for-a-new-field-type-to-eZ-Publish-Platform-UI.

 

Start the tutorial


 

Tutorial path