I'm trying to use hook_views_default_views_alter() to add fields to the view defined by another module.
I've tried:
1.
$views[$view_name]->add_item('default', 'field', $table_name, 'edit_link');
-- causes an out of memory error (on 256Mb)
2.
$views[$view_name]->display['default']->handler->options['fields']['edit_link'] = array(
'label' => 'edit link',
'id' => 'edit_link',
'table' => $table_name,
'field' => 'edit_link',
'exclude' => 0,
'relationship' => 'none',
);
-- seems to do nothing
3.
$fields = $views[$view_name]->display['default']->handler->options['fields'];
$fields['edit_link'] = array(
'label' => 'edit link',
'id' => 'edit_link',
'table' => $table_name,
'field' => 'edit_link',
'exclude' => 0,
'relationship' => 'none',
);
$views[$view_name]->display['default']->handler->override_option('fields', $fields);
-- out of memory error, it appears theme_status_messages() is full.
What's the correct way to do this?
Comments
Comment #1
joachim commentedThis advice from Dereine on IRC works:
Comment #2
joachim commentedHere's a patch for the docs.
Comment #3
joachim commentedSetting correct version.
Comment #4
dawehnerThanks man!
Commited to 7.x-3.x and 6.x-3.x