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 updated function _views_view_fields() to return the column names automatically. I needed it because I added a field to the view_view table and couldn't use it via hook_form_alter(). This code fixes it all but I didn't test it with pgsql.
function _views_view_fields() {
// return array('vid', 'name', 'description', 'access', 'page', 'page_title', 'page_header', 'page_header_format', 'page_footer', 'page_footer_format', 'page_empty', 'page_empty_format', 'page_type', 'use_pager', 'nodes_per_page', 'url', 'menu', 'menu_tab', 'menu_tab_default', 'menu_tab_weight', 'menu_title', 'block', 'block_title', 'block_use_page_header', 'block_header', 'block_header_format', 'block_use_page_footer', 'block_footer', 'block_footer_format', 'block_use_page_empty', 'block_empty', 'block_empty_format', 'block_type', 'nodes_per_block', 'block_more', 'url', 'breadcrumb_no_home', 'changed', 'query', 'countquery', 'view_args_php');
// Modification: ericdes Tela Web http://telaweb.fr
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$result = db_query('SHOW COLUMNS FROM {view_view} ;');
break;
case 'pgsql':
$result = db_query("SELECT column_name AS Field FROM information_schema.columns WHERE table_name = '{view_view}' ORDER BY ordinal_position ;");
break;
}
$columns = array();
while ($column = db_fetch_object($result)) {
$columns[] = $column->Field;
}
return $columns;
}
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedThis is not actually a patch, to start with.
And I'm not completely convinced Views should have this. Explain to me the value of this.
Comment #2
ericdes CreditAttribution: ericdes commentedI just want to avoid a modification needed for the Click2bookmark module. I added a checkbox to 'Allow users to bookmark this view'. Please let me know if you can think of a better way that wouldn't need an unwanted modification.
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedI took a brief look at your module. I don't feel like your module needs to do what it is doing the way it is doing it; adding random checkboxes to the already cluttered views UI seems like a very poor approach.