GithubHelp home page GithubHelp logo

prateekmehta / entity_embed Goto Github PK

View Code? Open in Web Editor NEW

This project forked from drupal-media/entity_embed

0.0 2.0 0.0 559 KB

Allows any entity to be embedded using a WYSIWYG and text format

PHP 92.56% JavaScript 7.44%

entity_embed's Introduction

Entity Embed Module Build Status

Allows any entity to be embedded using a WYSIWYG and text format.

Requirements

  • Latest dev release of Drupal 8.x as this module will not work with the last alpha release.

Configuration

  • Install and enable the module.
  • Enable the entity-embed filter 'Display embedded entities' for the desired text formats from the configuration page: '/admin/config/content/formats'.
  • Add <drupal-entity> to the 'Allowed HTML tags'
  • To enable the WYSIWYG plugin, move the entity-embed 'E' button into the Active toolbar for the desired text formats from the configuration page: '/admin/config/content/formats'.

Technical details

Users should be embedding entities using the CKEditor WYSIWYG button as described above. This section is more techincal about the HTML markup that is used to embed the actual entity.

Embed by UUID (recommended):

<div data-entity-type="node" data-entity-uuid="07bf3a2e-1941-4a44-9b02-2d1d7a41ec0e" data-view-mode="teaser" />

Embed by ID (not recommended):

<div data-entity-type="node" data-entity-id="1" data-view-mode="teaser" />

Display Plugins

<div data-entity-type="node" data-entity-id="1" data-entity-embed-display="entity_reference:entity_reference_entity_view" data-entity-embed-settings='{"view_mode":"teaser"}' />

A more advanced use for embedding entities uses an entity embed display plugin, provided in the data-entity-embed-display attribute. By default we provide four different display plugins out of the box:

  • default: Renders the entity using entity_view().
  • entity_reference:formatter_id: Renders the entity using a specific Entity Reference field formatter. For example, entity_reference:entity_reference_label renders the entity using the "Label" formatter.
  • file:formatter_id: Renders the entity using a specific File field formatter. This will only work if the entity is a file entity type.
  • image:formatter_id: Renders the entity using a specific Image field formatter. This will only work if the entity is a file entity type, and the file is an image.

Configuration for the display plugin can be provided by using a data-entity-embed-settings attribute, which contains a JSON-encoded array value. Note that care must be used to use single quotes around the attribute value since JSON-encoded arrays typically contain double quotes.

The above example renders the entity using the entity_reference_entity_view formatter from the Entity Reference module, using the teaser view mode.

entity_embed's People

Contributors

cs-shadow avatar davereid avatar slashrsm avatar berdir avatar stevector avatar nickschuch avatar jibran avatar webflo avatar boztek avatar unn avatar marcingy avatar

Watchers

James Cloos avatar Prateek Mehta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.