[Drupal] Howto change views2 sorting parameters programmatically.

Stub article, to be finished.
  1. function yourmodule_views_pre_view(&$view, &$display_id, &$args) {
  2. if ($view->name == 'your_views') {
  3. /* Get the Sort object */
  4. $sort = $view->display['default']->display_options['sorts'];
  5.  
  6. /* Change the sort order */
  7. $sort['name']['order'] = 'DESC';
  8.  
  9. /* Set the new sorting object */
  10. $view->display_handler->set_option('sorts', $sort);
  11. }
  12. }

No comments for '[Drupal] Howto change views2 sorting parameters programmatically.'

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <quote> <blockquote>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <pre>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.