modules. // 3. This module offers nothing in the way of permissions // 4. I have a busy work and family life, so sadly cannot offer much in the way of // support for this, beyond the needs of the websites I administer. // 5. Views holds a cache of table fields, so if new flexinode fields are added // to a content type, this cache must be cleared to pick the new field up. // To clear the cache, go to administer -> modules and click "Save configuration". // (Until such time that flexinode_admin calls a hook when a field is added/modified/deleted) // 6. No guarantees that non-text field type entries are going to display correctly, // and filtering or sorting on these fields is going to be flaky at best! // // ~gushie // ******************************************************************************************* /** * Implementation of hook_help(). */ function flexinode_views_help($section) { switch ($section) { case 'admin/help#flexinode_view': $output = '

Basic views support for Flexinodes... no security or anything so be careful!

'; return $output; case 'admin/modules#description': return 'Basic views support for Flexinodes... no security or anything so be careful!'; } } /** * Implementation of hook_views_tables(). */ function flexinode_views_views_tables() { $flexfields = db_query('SELECT t.name, f.* FROM {flexinode_field} f INNER JOIN {flexinode_type} t ON f.ctype_id = t.ctype_id ORDER BY t.name, f.label'); while ($field = db_fetch_object($flexfields)) { $field_id = $field->field_id; $fieldname = t('flexinode: '.$field->name.': '.$field->label); $fieldsort = flexinode_invoke('db_sort_column', $field); if(strstr($fieldsort, 'serialized_data')) $column = 'serialized_data'; elseif(strstr($fieldsort, 'numeric_data')) $column = 'numeric_data'; else $column = 'textual_data'; $tables["flexinode_data_$field_id"] = array( 'name' => 'flexinode_data', 'join' => array( 'left' => array( 'table' => 'node', 'field' => 'nid', ), 'right' => array( 'field' => 'nid', ), 'extra' => array( 'field_id' => $field_id, ) ), 'fields' => array( "$column" => array( 'name' => $fieldname, 'handler' => 'flexinode_views_views_field_handler', 'sortable' => TRUE, 'arbitrary' => array( 'field' => $field, ) ), ), 'sorts' => array( "$column" => array('name' => $fieldname, 'help' => t('Sort on this flexinode field')), ), 'filters' => array( "$column" => array( 'name' => $fieldname, 'operator' => 'views_handler_operator_like', 'handler' => 'views_handler_filter_like', 'help' => t('This allows you to filter by a flexinode field.'), ) ), ); } return $tables; } function flexinode_views_views_field_handler($fieldinfo, $fielddata, $value, $data) { $field = $fieldinfo['arbitrary']['field']; $field->options = unserialize($field->options); $fieldname = 'flexinode_'. $field->field_id; $tempnode->$fieldname = $value; $output = flexinode_invoke('format', $field, $tempnode, FALSE); $themefunc = 'flexinode_'.$field->field_type; return theme($themefunc, $field->field_id, NULL, $value, $output); }