Skip to main content
added 420 characters in body
Source Link
Nikit
  • 4k
  • 1
  • 20
  • 27

The snap code below has been tested only on D7. In case this code does not work on D6, check out the comments on this post here[post here][1].

function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
  if ($view->name == 'VIEW_NAME' && $display_id == 'DISPLAY_ID') {

    // To find out the DISPLAY_NAME, FIELD_NAME and FIELD_VALUE use the devel module function
    // below to print them out.
    // Replacing 'footer' by 'header' works the same way.
    dpm($view->display_handler->options['footer']['DISPLAY_NAME']['FIELD_NAME']);

    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'FIELD_NAME', 'FIELD_VALUE');

    // In this case scenario you needed to unset the footer display.
    // For the embedded view display you do like this:
    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'view_to_insert', '');
    // For the normal text area display you do like this:
    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'content', '');
  }
}

Due to comments, to determine what views name and display came to this function, make next (of course, "devel" module should be enabled)

    function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
      dsm($view->name);
      dsm($display_id);
      if ($view->name == 'VIEW_NAME' && $display_id == 'DISPLAY_ID') {
...
      }
    }

And update views page. [1]: http://drupal.org/node/749452 [2]: http://drupal.org/node/749452#comment-5433982

The snap code below has been tested only on D7. In case this code does not work on D6, check out the comments on this post here.

function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
  if ($view->name == 'VIEW_NAME' && $display_id == 'DISPLAY_ID') {

    // To find out the DISPLAY_NAME, FIELD_NAME and FIELD_VALUE use the devel module function
    // below to print them out.
    // Replacing 'footer' by 'header' works the same way.
    dpm($view->display_handler->options['footer']['DISPLAY_NAME']['FIELD_NAME']);

    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'FIELD_NAME', 'FIELD_VALUE');

    // In this case scenario you needed to unset the footer display.
    // For the embedded view display you do like this:
    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'view_to_insert', '');
    // For the normal text area display you do like this:
    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'content', '');
  }
}

The snap code below has been tested only on D7. In case this code does not work on D6, check out the comments on this [post here][1].

function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
  if ($view->name == 'VIEW_NAME' && $display_id == 'DISPLAY_ID') {

    // To find out the DISPLAY_NAME, FIELD_NAME and FIELD_VALUE use the devel module function
    // below to print them out.
    // Replacing 'footer' by 'header' works the same way.
    dpm($view->display_handler->options['footer']['DISPLAY_NAME']['FIELD_NAME']);

    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'FIELD_NAME', 'FIELD_VALUE');

    // In this case scenario you needed to unset the footer display.
    // For the embedded view display you do like this:
    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'view_to_insert', '');
    // For the normal text area display you do like this:
    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'content', '');
  }
}

Due to comments, to determine what views name and display came to this function, make next (of course, "devel" module should be enabled)

    function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
      dsm($view->name);
      dsm($display_id);
      if ($view->name == 'VIEW_NAME' && $display_id == 'DISPLAY_ID') {
...
      }
    }

And update views page. [1]: http://drupal.org/node/749452 [2]: http://drupal.org/node/749452#comment-5433982

TryThe snap code below has been tested only on D7. In case this code does not work on D6, check out the comments on this next:post here.

<?php
//I had a view with 3 attachments so I used the $display_id to limit the function
function YOURMODULENAME_views_pre_viewMYMODULE_views_pre_view(&$view, &$display_id, &$args) {
 
    if ($view->name == 'YOURVIEWNAME''VIEW_NAME' && $display_id == 'YOURDISPLAYID''DISPLAY_ID') {
       
    // To find out the DISPLAY_NAME, $footerFIELD_NAME =and "ThisFIELD_VALUE isuse the text that I want indevel mymodule footer!!!!";function
     // below to $optionsprint =them array(out.
      // Replacing 'footer' by 'header' works 'id'the =>same 'area',way.
            'table' => 'views',dpm($view->display_handler->options['footer']['DISPLAY_NAME']['FIELD_NAME']);
            'field' => 'area',
           $view->set_item_option($display_id, 'empty''footer', =>'DISPLAY_NAME', FALSE'FIELD_NAME', 'FIELD_VALUE');

    // In this case scenario you needed to 'content'unset =>the $footer,
footer display.
    // For the embedded view display you 'format'do =>like 2,this:
    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'view_to_insert', '');
    'tokenize'// =>For 0,
the normal text area display you do like );this:
        $view->set_item>set_item_option('YOURDISPLAYID'$display_id, 'footer', 'area''DISPLAY_NAME', $options'content', '');
 
       }
}
?>

Try next:

<?php
//I had a view with 3 attachments so I used the $display_id to limit the function
function YOURMODULENAME_views_pre_view(&$view, &$display_id, &$args) {
 
    if($view->name == 'YOURVIEWNAME' && $display_id == 'YOURDISPLAYID') {
                $footer = "This is the text that I want in my footer!!!!";
        $options = array(
            'id' => 'area',
            'table' => 'views',
            'field' => 'area',
            'empty' => FALSE,
            'content' => $footer,
            'format' => 2,
            'tokenize' => 0,
        );
        $view->set_item('YOURDISPLAYID', 'footer', 'area', $options);
 
       }
}
?>

The snap code below has been tested only on D7. In case this code does not work on D6, check out the comments on this post here.

function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
  if ($view->name == 'VIEW_NAME' && $display_id == 'DISPLAY_ID') {
 
    // To find out the DISPLAY_NAME, FIELD_NAME and FIELD_VALUE use the devel module function
    // below to print them out.
    // Replacing 'footer' by 'header' works the same way.
    dpm($view->display_handler->options['footer']['DISPLAY_NAME']['FIELD_NAME']);

    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'FIELD_NAME', 'FIELD_VALUE');

    // In this case scenario you needed to unset the footer display.
    // For the embedded view display you do like this:
    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'view_to_insert', '');
    // For the normal text area display you do like this:
    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'content', '');
  }
}
Source Link
Nikit
  • 4k
  • 1
  • 20
  • 27

Try next:

<?php
//I had a view with 3 attachments so I used the $display_id to limit the function
function YOURMODULENAME_views_pre_view(&$view, &$display_id, &$args) {

    if($view->name == 'YOURVIEWNAME' && $display_id == 'YOURDISPLAYID') {
                $footer = "This is the text that I want in my footer!!!!";
        $options = array(
            'id' => 'area',
            'table' => 'views',
            'field' => 'area',
            'empty' => FALSE,
            'content' => $footer,
            'format' => 2,
            'tokenize' => 0,
        );
        $view->set_item('YOURDISPLAYID', 'footer', 'area', $options);

       }
}
?>