You are here

function properties_sql_properties_template_load_multiple in Dynamic properties 7

Load multiple templates based on their names.

Parameters

$names: Array of machine readable name of the templates.

1 call to properties_sql_properties_template_load_multiple()
properties_sql_properties_template_load in properties_sql/properties_sql.module
Load a template based on the name.

File

properties_sql/properties_sql.module, line 274
This module implements the attribute and category API with a SQL backend.

Code

function properties_sql_properties_template_load_multiple($names = array()) {
  $templates = db_select('properties_template', 'pt')
    ->fields('pt')
    ->condition('name', $names)
    ->addTag('translatable')
    ->addTag('properties_template_load')
    ->execute()
    ->fetchAllAssoc('name');
  foreach ($templates as $template) {
    $template->categories = array();
  }
  $query = db_select('properties_template_category', 'ptc')
    ->fields('ptc')
    ->condition('ptc.template_name', $names)
    ->addTag('properties_template_category_load')
    ->orderBy('ptc.weight');
  $query
    ->join('properties_category', 'pc', 'ptc.category_name = pc.name');
  $result = $query
    ->fields('pc')
    ->execute();
  foreach ($result as $category) {
    $templates[$category->template_name]->categories[$category->name] = $category;
  }
  return $templates;
}