Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#2 | group_views_new.txt | 5.29 KB | edward.ishaq |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedI 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.
Comment #2
edward.ishaq CreditAttribution: edward.ishaq commented<?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
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedRIght 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.
Comment #4
edward.ishaq CreditAttribution: edward.ishaq commentedthanks :)
This explains my question.
Comment #5
catch