Skip to content

Example module demonstrating the use of Drupal 7's EntityFieldQuery API

Notifications You must be signed in to change notification settings

timcosgrove/efq_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

For the purposes of a series of blog posts on EntityFieldQuery, I've created a simple module that demonstrates some uses of EntityFieldQuery.

Some quick notes about what the module contains: the module installs three node types, efq_article, efq_page, and efq_photo. These are very simple node types: efq_article and efq_page each contain a body field for text, while efq_photo contains a single image field. In addition, all three content types contain a US States field, which we'll be using to construct some example queries.

Additionally, the module defines a menu callback that uses EntityFieldQuery to generate a listing of these content types that is filterable by state and by node type arguments. It also defines a block which lists other content in the system that matches the state of a given node, if such content exists.

I recommend using Devel content generate to quickly generate content for your examples, although you can of course create it manually if you like. For the purposes of my examples, I created 200 nodes using the following command: drush genc --types="efq_page,efq_article,efq_photo" 200.

When you uninstall this module, it will clean up after itself, removing all created content. I'm thinking of teaching this technique to my cats.

About

Example module demonstrating the use of Drupal 7's EntityFieldQuery API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages