Home > Drupal-module--Uniqueness-API

Drupal-module--Uniqueness-API

Drupal-module--Uniqueness-API is a project mainly written in PHP, it's free.

Provides an API and schema to store, retrieve and calculate uniqueness for Drupal content.

Provides an API and schema to store, retrieve and calculate uniqueness for Drupal content.

The API stores a key that represents the content that you would like to remain unique across the site. The key is limited to 255 characters to provide for efficient lookup and comparison. The entire value of the content is also stored, in the case that there are more than one identical 255-character keys but unique content values. It provides two core functions: uqapi_is_unique() and uqapi_are_unique(). Function arguments can be found in the module.

An example might be blog node titles -- you do not want any duplicate blog node titles to be submitted. Therefore, you would call uqapi_is_unique() on $node->title in hook_nodeapi() when $node->type == 'blog'. See the example below.

/**

  • Example implementation, using hook_nodeapi
  • */ function uqapi_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { switch ($op) { case 'validate': if ($node->type == 'blog' && !uqapi_is_unique($node->title, 'blog_title')){ form_set_error('title', t('Please create a blog title that is unique.')); } break; } }

Previous:Kohana-Braintree