i was wondering how can i tell which of drupal's fields i can add handlers for and which i cant.
my goal is to attach a handler to a node field.

Files: 
CommentFileSizeAuthor
#2 group_views_new.txt5.29 KBedward.ishaq

Comments

merlinofchaos’s picture

I don't really understand the question.

You can attach a handler to any field, simply by creating an aliased version of the table and then creating a field entry for the field you want.

edward.ishaq’s picture

StatusFileSize
new5.29 KB

<?php
function diary_views_tables() {

$tables["node"] = array(
'name' => 'node',
'join' => array(
'left' => array(
'table' => 'node',
'field' => 'nid'
),
'right' => array(
'field' => 'nid'
),
),
'fields'=>array(

'nid'=>array(
'name'=> t('RC Fields: node.nid'),
'sortable'=>false,
'handler' => array(
'group_image_handler' => t('My handler for the image (edy)'),
'test_handler' => t('a test handler'),
),
),

'title'=>array(
'name'=> t('RC Fields: node.title'),
'sortable'=>false,
'handler' => array(
'group_image_handler' => t('My handler for the image (edy)'),
'test_handler' => t('a test handler'),
),

'status'=>array(
'name'=> t('RC Fields: node.status'),
'sortable'=>false,
),

'type'=>array(
'name'=> t('RC Fields: node.type'),
'sortable'=>false,
)
),
),
);
}

when i attach handlers to the node table the node fields disappear from the UI of the Views.
and i cant select the node.type to filter on it later , and it generates error on other views too .

my question is how to attach another handler on the node.* fields , is the only way is hacking the node view module of drupal or is there a way i can do it from my module

merlinofchaos’s picture

RIght The important part of this is that you need to alias the table. It'll create a less efficient query, but for now it's your choice.

Instead of $tabes['node'] = array(

Try $tables['rc_node'] = array(

The 'name' immediately below it will make it pick the correct table. Now, the downside is that, yes, it'll end up joining an aliased version of the node table in, so the query won't be as good. But for now that's the only method you have of adding new behavior to existing node fields.

edward.ishaq’s picture

thanks :)

This explains my question.

catch’s picture

Version:6.x-2.x-dev» 5.x-1.x-dev
Status:Postponed (maintainer needs more info)» Closed (fixed)