Skip to main content

Entity metadata wrappers to the rescue - Drupal 7

Updated by Tim Rabbetts on
computer, computer code, programming

This wrapping class is provided by the Entity API module, which I would highly recommend you run (more than likely you already are as it is required by some other modules).

How to use the API

// use entity metadata wrappers as they are SMART
$wrapper = entity_metadata_wrapper('node', $node);
dsm($wrapper->getPropertyInfo());

This will print out a list of all known fields on the node, and you can access properties easily. Once you have the $wrapper object defined you will now be able to use the below advanced syntax for quering values of fields.

Add new comment