Questions about the entity API, the API that allows to create entities in Drupal 7 and forward.
0
votes
1answer
11 views
access field data in template.php and create variable for header image in page.tpl.php
I am trying to allow the user to set a custom image to display in the header on node pages that have a header_image field and to display a default header image on all other pages (including system and ...
0
votes
0answers
8 views
Get list of all entities that have a reference (via organic groups) to another entity (different bundles)
I have a "Date" entity and an "Event" entity. Dates can be linked to Events via Entity Reference using the OG Reference widget. I am having trouble getting all of the dates for a specific Event. I ...
0
votes
1answer
14 views
How should I implement an alternative file upload?
I want to write a module for Drupal 7 to integrate http://filepicker.io's awesome functionality. It's a simple JS widget that returns a URL of where the file is hosted.
I've never written a D7 module ...
0
votes
1answer
13 views
Additional fields for Ubercart uc_order_product
I need to add fields to the Ubercart entity uc_order_product. I was looking into the function field_create_instance, but don`t know exactly where to use it. I believe I should attach the field I want ...
0
votes
0answers
33 views
How to clone a entity with its attached fields?
I am trying to create a entity with few bundles. I have used EntityDefaultUIController as admin UI callback. This provides me with few default functions such as clone, import and export. The problem ...
0
votes
0answers
31 views
Can't add content?
I have a content type called Video with a node title and a video field where i put the url of the youtube video i want ( Video Embed Field module ) .
Everything goes fine until i installed some ...
3
votes
1answer
32 views
Session breaks Entity API
Whenever I try to use $_SESSION or variable_set it breaks the Entity API. It says
"Fatal error: Call to undefined function entity_get_info() in
...
1
vote
1answer
28 views
How to change content type field values with the entity system — getting a “doesn't support writing” error
I've got a D7 content type with a few fields; nothing particularly special. I want to be able to programattically change the values of those fields from time to time, and so wrote a function like so:
...
4
votes
1answer
110 views
How to set value of file field with entity_metadata_wrapper
How do you set the value of a file field when using the entity_metadata_wrapper?
I've tried doing this in code:
$file = new stdClass();
$file->uid = 1;
$file->uri = $file_path;
...
0
votes
0answers
33 views
Attach Entity “comment” to Entity “file”
Files (images) are uploaded within a content type with plup and plupload. These images are then displayed through a view.
I would like to have a "commenting" functionality for each uploaded image. I ...
5
votes
1answer
82 views
How do you clear a field value with entity_metadata_wrapper()?
Suppose I have an entity with a field field_foo on it and I want to clear that field's value.
What should I pass to $wrapper->set()?
I have tried NULL and array() and both produce an error ...
3
votes
4answers
109 views
How can I get bundle of an entity from type and id?
I need to identify bundle of an entity from its type and id.
For example, if the type is 'node' and id is 7, I may get 'page' as bundle.
Thanks
0
votes
1answer
40 views
creating a custom entity which stores multiple bundles as per user input?
I want to create an custom entity(Lets say payroll entity) which has the following fields
1. Basic salary
2. Earnings
3. Deductions
It is possible by Entities
But now I would like to add some new ...
7
votes
1answer
220 views
Is EntityFieldQuery really this inefficient?
I am an admitted newbie to the Entity API, but am trying to cure that. I'm working on a site that uses a number of content types with various fields attached to them; nothing fancy. So, when I want ...
1
vote
1answer
30 views
how to check non existent field added later using entityfieldquery? [duplicate]
I added a required field in a Job type node later. So existing nodes don't have that particular field value.
I want to include all such field values. But how can I do it?
Here is query sample:
...
3
votes
1answer
81 views
how to define entity preprocess function
My custom module defines a custom entity, which extends the EntityAPIController class. I managed to make it basically working, i.e. displaying fields etc via my custom tpl.php file. But I would like ...
1
vote
1answer
35 views
Using Entity API, if given an entity in a function scope, how do you get the entity type?
This is very similar to this question: How do I get entity_type and entity_id from any entity page?
But I don't know what that asker means by "Entity Page," and in my case, using debug_backtrace ...
3
votes
1answer
87 views
Should I create fielded content types (with 1000+ tables) OR create custom entities with properties instead of fields (way less tables)?
I have a case where I have a lot of entities that can be stored with Drupal as node (content types) and fields. I had to end up creating 105 content types, 20 taxonomies and in-numerous fields. And ...
0
votes
1answer
43 views
Cleanest way to write EntityCondition on field from widget
The widget is nodehierarchy_menu_links - it has a structure embedded in the node like:
[0]
-> [module]
-> [menu_name]
...
-> [pnid]
It has more than one value as per the widget system. I ...
6
votes
2answers
172 views
Accessing values of unknown field types when using entity_metadata_wrapper
I've been looking into using the Entity Metadata Wrapper classes (defined by the entity module in Drupal 7) to access field values, as this seems to be a clean way of doing so.
There a couple of ...
-2
votes
2answers
40 views
How to know node/entity ID from a submit handler?
How to know node/entity ID from a submit handler of a form created with hook_form()?
I need to make db_update() query on a single row from submit handler called by admin/structure/video/manage/% form ...
3
votes
2answers
58 views
Returning body values only
I have the following function that simply grabs nodes:
function getWords() {
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node', '=')
...
1
vote
1answer
47 views
Controller classes in Entity API
I'm trying to follow this article to build my first entity using Entity API module. I'm unclear about the dependency between controller classes and include files. If it says:
'controller class' => ...
0
votes
1answer
53 views
How do I write to location field in an Entity?
I am having a custom entity called Micronews which has a bundle microupdate created in it. I am able to write entity to db for all fields but I am not able to figure out how to write location (using ...
0
votes
1answer
160 views
Pre-populate default values into a form to edit a new entity
In a Drupal 7 site, I have created a new entity called "atomyx_portal_metadata". This entity works great in all respects. I allow people to define their own entity types (much as you can create your ...
0
votes
2answers
107 views
Remove title from hook_entity_view
I need to remove title from rendered custom entity.
unset($entity->title) is not good because i still need to use its value in this rendered entity to use in markup.
css display:none is not good ...
0
votes
0answers
32 views
Cannot get field/display options to display with entity
I've built an entity that declares a fieldable type of true, and yet when I go to a defined administration page to add a new entry, I cannot find any links pointing to the field creation prompts. I'm ...
0
votes
0answers
43 views
Implementing revisions in an entity
I'm in the process of building an entity that extends DrupalDefaultEntityController, and I have some questions about the uses of the revisions mechanism, namely if I need to duplicate all the fields ...
1
vote
1answer
268 views
Drupal 7 Faceted Search: Always show Facets
I have a faceted search working that uses searchapi, facetapi, and entityapi. I was not the one who developed this, but I have some experience with Drupal. As of now the navigation uses links for ...
1
vote
0answers
79 views
When should I use hook_field_attach_presave(), and when hook_entity_presave()?
I was looking for a way to act on entity fields before they are saved, and I have noticed the following about hook_field_attach_presave(), and hook_entity_presave():
They take the same parameters, ...
0
votes
0answers
108 views
Rendering all fields of an entity (i.e. viewing the entity)
I am trying to render all of the fields attached to a custom entity. This will be used for "viewing" entity, like you would view a node or a user, etc.
I first tried to use field_attach_view:
...
0
votes
1answer
163 views
Unsure how to define an entity type using Entity API
I'm here because of this:
EntityMalformedException: Missing bundle property on entity of type contacts. in entity_extract_ids()
I'm trying to create my own entity. Can you identify what is ...
0
votes
0answers
62 views
D7 integration of entity with Views
I just CANNOT get my custom entities to be visible in Views.
I've done this before successfully, but I cannot for the life of me figure out why this isn't working now. I've tried uninstalling and ...
0
votes
1answer
145 views
Entity API fieldable entity path issue
So, after studying several examples, I started writing my own module to implement a notification-like entity.
I wanted it to allow separate bundles and be fieldable. This example was a great guide to ...
0
votes
1answer
77 views
How would I use entity wrapper to insert new values into an entity property list? bundle?
I would like to save a list of values into a entity property.
foreach ($results as $result)
{
$wrapper->title->set(value);
}
Can an entity property hold an array of values or would I use ...
0
votes
0answers
27 views
Create new entity references based on lastfm lookup using the entity api
I have an entity, that I want to then create entity references for using the entity api.
I am doing a look up on the lastfm api to compare artist names with my entity with contains an artist name.
...
0
votes
0answers
105 views
how to define template_preprocess for custom entity type in module?
i have a custom entity type defined in a module. I have extended Model entity project to create new entity type. My entity is themed with a key: myentity. Somehow template_preprocess_myentity() not ...
0
votes
0answers
97 views
How to create add new entity form on a template file?
i am struggling now for days trying to display a form where users can add new 'custom_entity' content. I have already tried following scripts:
<?php print ...
3
votes
4answers
698 views
Getting a field's value from an entity
What I have installed on my site is the Entity API and Entityform modules. The Entityform module allows me to create forms that any user can submit and the forms fields are available for me to use in ...
1
vote
0answers
41 views
Pulling Values from $order in Commerce Cart
I am trying to pull the value of a selected item in a field list located in the order entity. Later this is used to determine what panes should be shown in the checkout workflow. I should note that ...
2
votes
2answers
141 views
Upload file and fill in fields in one step; or trigger a rule when a file is uploaded
I want to make use of the Media module and the File entity module to upload files, in particular images, to my Drupal 7 site without having to attach them to a node. Solely uploading images works like ...
1
vote
1answer
502 views
Storing images as nodes in Drupal 7
I am building a Drupal 7 platform where users can share images. In a nutshell, people should be able to comment on images and like them.
The way I realized this is by creating a custom content type ...
1
vote
0answers
123 views
Dependency problem with Entity API + Rules + Features at deployment
I'm saving rules in a feature. I added a new rule that has as dependency a module that I added to the project's repo. This new module was correctly added to the feature's dependency list in the .info ...
2
votes
2answers
422 views
How to programmatically create an entity and fill in entity reference fields
I'm trying to create an entity that has a number of entity refernce fields, and I'm confused about the best way to do that. so far I've gotten as far as this
$entity = entity_create('mytype', ...
1
vote
2answers
192 views
D7 pseudo-fields and custom entity properties from additional schema
I'm trying to add property information to an entity which uses the entity api. Working from the commerce_product module I am trying to manage additional information outside of fields and in my own ...
3
votes
1answer
415 views
Entity API - does everything need a bundle?
I'm learning about the Entity API. I have a simple extra table that I'd like to "drupalize" so that I can use it in Views, for example.
I've read quite a bit, watched a few videos, looked at quite a ...
3
votes
2answers
591 views
How does Drupal know which Entity View Mode to use?
When Entity View Modes are defined, how does Drupal know which to use? Are they only useful with Views, or can they be used in the node display as well? If so, is that specified in the template, or ...
2
votes
2answers
58 views
Adding to that list of display options that includes “Default” and “Teaser”
Under structure > content types > manage fields, there are display options in the upper right. The system-defined ones are "default" and "teaser" but I have seen "tokens" and "colorbox" added by ...
1
vote
1answer
221 views
How do I use entity_metadata_wrapper to create a node and at the same time multiple node references?
I have an XML response from a REST api call that returns an object with an array of sub-objects contained in it.
I need to create a node with all the properties of the top level object and node ...
1
vote
1answer
81 views
Pass data to hook_entity_insert
How can I pass data to hook_entity_insert() given that the arguments it takes are fixed?
I'm writing to the database during entity save, and need to be able to pass some data in this hook.
