Questions about the entity API, the API that allows to create entities in Drupal 7 and forward.

learn more… | top users | synonyms

0
votes
0answers
19 views

Unable to edit new custom entity column values added to existing entity schema

I've added a new varchar column via a module update to an entity. The new entity property's default value displays for existing records on forms but changes are not saved. I say "forms" because there ...
0
votes
2answers
15 views

Add values to an existing custom entity bundle

I've created a custom entity with bundle and added 3 fields to the bundle(namely recipient, sender, flag). How can I add values to it programmatically. Any help would be appreciated. Thanks
0
votes
0answers
26 views

The save() function permanently alters content when used with hook_preprocess_html. Is there a way to do the same thing for a single view instance?

I was planning to use an entity wrapper to conditionally fill in a (potentially) empty field. The use case is the following: Some users want to manually fill in the field with machine name ...
1
vote
0answers
13 views

How to use a field as an entity's property

My module provides its own entity. I need my entity to have a link field with multiple values. The module link is suitable for this. At install hook, I create a field and a field instance of link ...
0
votes
1answer
26 views

Which is the best way to create an entity? [closed]

I would like to use entity concept in my next project.So , is it good to use Entity Construction kit for creating entities ? How about Model Entities ? Which is better ?
2
votes
2answers
29 views

How to check if entity's property has a value

How can I check if entity's property has a value? I don't think this is the "drupal way" to check it like this $page_optimization->title->value() !== '' Is there any method, something like ...
2
votes
2answers
22 views

How can I entity edit path?

I made a module, and defined my custom entity there. I set admin ui interface 'admin ui' => array( 'path' => 'admin/structure/optimizations', ), Then is some code, I have my entity object. ...
1
vote
1answer
45 views

Is it proper to perform a db_update on an entity table?

I have a custom entity. During a save operation, under certain circumstances, I need to change the value of a specific field (not field API) of some other entities (of the same type). If I perform a ...
1
vote
1answer
35 views

Custom Entity with a uid property [closed]

We seem to be experiencing a very unexpected problem. We have created a custom entity called feature and it has a uid property. The schema is as follows: $schema['feature'] = array( 'fields' => ...
0
votes
1answer
9 views

entity_export - where can it be used?

I want to make use of the entity_export function for data migration. I see on the doc page http://drupalcontrib.org/api/drupal/contributions!entity!entity.module/function/entity_export/7 that Note: ...
0
votes
2answers
28 views

Get the last revision id of any given entity?

Is there a single, unified method in Drupal 7 to get the last revision id for any given entity object? If so, what is that method?
0
votes
2answers
50 views

Difference between a bundle and a conten type

Can somebody explain to me the difference between a content type and a bundle? Is the latter just a bundle for the entity node?
0
votes
1answer
28 views

anonymous User broken

I just migrated the site from sqlite to Postgres, using the drush portabledb-import module I'm getting a error page only when no user is logged in to the site. I can get logged in using the ...
0
votes
0answers
16 views

How to extend entityreference field by another custom field?

I want to add another field, which needs to be accessible by views (for display and ordering), to the entityreference table field_data_field_FIELDNAME. Structure of that table is: entity_type ...
3
votes
2answers
77 views

Minimizing the time taken for entity_load while using for apachesolr indexing

I am working on a site with a specific node type that has close to 50 fields, most of which are taxonomy term references, a couple of node references and a few conventional text and integer values. ...
0
votes
1answer
17 views

Using tokens with entities?

I'd like to be able to use tokens with entities, similar to how they work for node right out of the box with core. However, for whatever reason, entity tokens are not available to me even though I ...
0
votes
1answer
31 views

Is there an hook to react to custom entity updates?

I need to react to updates of custom entities wich are using Entity API (Redhen organization in my case). I tried using hook_entity_update($entity, $type) but it does not seem to be fired when ...
0
votes
0answers
44 views

Entity API error “EntityMetadataWrapperException” when saving Article

So, I've been facing this issue since last week and I'm not sure what's causing it: EntityMetadataWrapperException: Unknown data property field_mailing_list. in ...
0
votes
2answers
106 views

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityMetadataWrapper->set()

I am creating nodes programmatically. I Have written following code, $e = entity_create('node', array('type' => 'some_node')); // Specify the author. $e->uid = 1; // Create a Entity Wrapper of ...
1
vote
2answers
54 views

load commerce coupon

I want to load coupons that have commerce_discount_reference=4. I find that can load them by commerce_coupon_load_multiple but I dont know how I add condition commerce_discout_reference=4. maybe ...
2
votes
0answers
23 views

How can I show all translations of a field in a node

I am working on a relatively simple multilingual site. I only need to translate the title of each node, so I thought a lightweight approach through entity translation and the title modules would be ...
2
votes
2answers
158 views

Programmatically create a node with alias and menu item using Entity API

I've seen the excellent documentation on Drupal.org about how to create a node in code, but that documentation doesn't address how to create the node's alias. I've seen code snippets that use ...
1
vote
0answers
32 views

Dates display incorrectly on node display after programmatic creation

Problem I have a form where users can create a node by filling in a number of fields. It creates a node using the Entity Metadata Wrapper as shown here. I have two date fields on this form, however ...
1
vote
2answers
85 views

How to redirect views of entity types (bean) for user roles?

RabbitHole does not provide this functionality for bean blocks and Entity Bundle Redirect does not seem to work. There is a user role which may edit bean blocks but I want to prevent them from viewing ...
2
votes
1answer
54 views

$entity_wrapper->save(true) vs. entity_save('node', $entity)?

Say I've got the following block of code: $language = language_default(); $values = array([...]); $entity = entity_create('node', $values); $entity_wrapper = entity_metadata_wrapper('node', ...
3
votes
1answer
90 views

What does the entity_view function do?

After reading the documentation and searching through code, I can't quite figure out what the entity_view function is for. The documentation explains it executes the view callback if defined, with a ...
2
votes
1answer
162 views

Can I avoid creating a new revision of every attached field upon entity save?

I have created a custom entity with several properties and several attached fields. When I load a instance of my custom entity, update a property of the entity (e.g UID) and save it a new revision of ...
0
votes
1answer
90 views

Create bundles programmatically using ECK (Entity Construction Kit)

The ECK module allows users to create custom entities. When using this modules UI it is possible to create an entity type, and then attach multiple bundles to the entity. It is also possible to ...
1
vote
2answers
64 views

select nodes title start with charachter

I want to have query with EntityFieldQuery that return me nodes with title start with A or B but has not obvious method to use or in property condition, I dont want use db_select or db_query. in this ...
0
votes
0answers
31 views

or condtion in EntityFieldQuery [duplicate]

I want use or in EntityFieldQuery query, I search and found this but I dont understand how can I implement this, please instead of refer to another link or article tell me how can I add or condition ...
1
vote
0answers
10 views

pager in EntityFieldQuery [duplicate]

I know I can have pager with db_select as example $query = db_select('node', 'n') ->condition('type', 'article') ->fields('n') ->extend('PagerDefault') ...
2
votes
3answers
188 views

Entity Metadata Wrapper Save VS Node Save when invoked from hook_node_insert

Can somebody shine a light into the difference of the two, in terms of their interaction with database when hook_node_insert() is invoked? The documentation explains that Note that when this hook ...
1
vote
1answer
46 views

Proper way to cache custom entities with Entitycache?

I am trying to figure out how to cache custom entities with Entitycache module. As I know Entitycache module doesn't support custom entites created with Entity API, that's why I'm doing like this: ...
0
votes
2answers
22 views

How to add more data to a field

I'm trying to find the best way to extend a field's data set (not even sure of the right terminology). What I want, is to attach some other information to an existing field. Let's take a file field, ...
0
votes
1answer
43 views

EntityDrupalWrapper->value() causes infinite recursion on user login?

I have a few instances on my site where I perform actions on User Login. I create an EntityMetadataWrapper like so: global $user; $uw = entity_metadata_wrapper('user', $user); And then I go to ...
0
votes
0answers
8 views

different text list by entity in Commerce

I am using Profile2 and Drupal Commerce. I have a profile which should have a text list with some products sku. Then, with Rules I would check if the product SKU is into the current user sku list and ...
0
votes
0answers
23 views

hook_node_view() creates extra content, but shows only after frequent cache clear

I have create a custom content type, and wanted to add link on the bottom of each node of that content type. So I used "hook_node_view" for creating extra content. The content created by ...
1
vote
0answers
9 views

Is there a way to take a configured entity reference field and attach it as-is in a custom module?

I have an entity reference field that I've configured and have added to a content type. Is there a way to take that same field and attach it with it's configuration in a custom module? I can attach ...
1
vote
1answer
105 views

What is a Drupal Entity URI?

This is a very simple question, yet sometimes I struggle finding a concrete and straightforward answer to it: What are Drupal entity URIs? What are they used for? Every answer I see is like - Just ...
0
votes
1answer
41 views

Store array of ids in a field programmatically?

Devel noob here. I am writing a module where I need to stash a list of entity ids in a field on a different entity. I've created a field on an entity type programmatically and have it set as field ...
1
vote
1answer
48 views

How are Field API fields transfered from config entities to content entities?

So I am creating a content and config entities - exactly like node and node type. After I've created them I've noticed that I can add fields to the config entities, which is ok but then I've realised ...
0
votes
1answer
32 views

What does data column do in both {someentity} and {someentity_type} base tabels?

It is my first time that I actually want to make use of Entity API module. I looked at different modules like profile2 which has implemented their module with Entity API. I do not exactly understand ...
2
votes
1answer
40 views

Module hook to add_js to any entity type?

I want a hook that will let me conditionally add js/css to the page depending on the type of entity. Since I am putting this in a module I cannot use a theme hook (because if the theme already ...
0
votes
0answers
56 views

How to display sub field values in EFQ Views Backend?

Context : Drupal 7 Custom Entities using Entity API Custom Fields using FieldAPI Mongo Storage engine for all fields, incl. custom fields EFQ Views Backend I have a D7 site with custom entities, ...
0
votes
0answers
24 views

Query a field collection for a null value

In Drupal 7, I am trying to query a field collection for a null value (no references have been assigned) using the Entity API, but it appears to ignore the entity condition and returns all results. ...
0
votes
1answer
96 views

Sanitized text input for EntityMetadataWrapper set()

Through searching, I've found plenty of examples using the EntityMetadataWrapper set() function to update entity fields, and have implemented it successfully in my module. However, I haven't been able ...
2
votes
1answer
47 views

How to add template suggestions for entities?

I need to add a template suggestion for entities in a custom module, similar to how you can add one for nodes. I've seen the ones implemented in the Entity API module, but how do I hook into entity ...
0
votes
1answer
229 views

Creation of entity with image field on drupal 7

I would like to generate an entity that contains image generated by another module file in drupal 7. This is my code : //appel de la variable user global $user; //recuperation de lapercu $apercu = ...
0
votes
2answers
34 views

Drupal Home page permission

I forbid content access to all user that are not connected. The problem is that Drupal prevent also the access of the main page (And I want that an anonymous user will be able to see it..). How can I ...
0
votes
1answer
145 views

Saving date field programmatically on node, but not on profile

I'm saving some date field on the code both on node and profile entity. I'm success on saving it for nodes, but when i try to save for profile2 entity, using the same chunck of code, no data is saved. ...