Entity Insert

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Kars-T's picture

Hi

we need the function of the http://drupal.org/project/insert module but for any entity type.

So we think of writing a module that uses a json token like the media module does.

[ [{"type":"media","view_mode":"media_large","fid":"4","attributes":{"alt":"","class":"media-image","height":"360","width":"480"}}] ]

We believe this is the best way to add field collections into the content of the node.

The use case is that you might want to add something like a table, HTML structure to your filterable content. You could use HTML directly or a WYSIWYG editor. But there is no abstraction or collection of your data.

So you add a field collection or maybe a node / entity reference. But how do you get this into your text?
So we try to provide a token on a common base that loads an entity and renders it with a given display and maybe some settings. This is a little step to an asset management so you can put any data in any entity and reuse it in any filtered text field.

Comments

Checked out node_embed?

arpieb's picture

Node Embed (http://drupal.org/project/node_embed) gives you the ability to embed nodes in content via WYSIWYG, might be something to look into as a starting point for generic entity embedding or maybe join forces on...

Entity Embed

sreynen's picture

There's an entity embed sandbox here:

http://drupal.org/sandbox/benubois/1567862

I'm happy to help explain anything in Node Embed, but I think it entity embedding should remain a separate projects, since the name of "Node Embed" would just be confusing for anything other than nodes.

This sounds like a great

gmclelland's picture

This sounds like a great project.

These are also a little similar:
http://drupal.org/project/token_insert
http://drupal.org/project/token_filter

Thanks guys!

Kars-T's picture

Thank you for the comments. I will look through the modules and think of a strategy :)

Filter is ready but...

Kars-T's picture

Okay the filter was an easy thing. We use it to insert field collections. The real problem is we are not safe of endless recursions. It is absolutely impossible to stop this because we have no context of the entity we are currently in. So inside of hook_filter_process() we have no clue where we are comming from.

Still we will make a sandbox later.

Limiting recursion

sreynen's picture

While there's no entity context on the first call to hook_filter_process(), you could save a list of entities you're about to render within that entity and prevent all but the first from being rendered recursively. That should be enough to prevent infinite recursion, though it wouldn't prevent all recursion.

Recursion

Kars-T's picture

Yes we talked about this. But if you use something that you want to insert several times on different nodes it wouldn't work any more. I think we can't do load an entity only once. Maybe as an option for the filter thought.

sandbox is here

Kars-T's picture

http://drupal.org/sandbox/Caseledde/1606312

But you will need documentation to use it...

Any updates

seanr's picture

Can you provide some documentation or at least basic explanation? I see in the code a form to select entities, but it does not render anywhere for me and I am unable to determine how to get it to show up.