I'm not sure if this is the best way to do it, but I needed to alter a view that was being displayed in a panel before the $nodes list is generated, normally done with the hook_views_alter* functions.

This patch adds a simple hook to alter panel_views before they are rendered...

Index: panels_views.module
===================================================================
--- panels_views.module (revision 14)
+++ panels_views.module (working copy)
@@ -808,6 +808,13 @@
   $offset = ($pv->allow_offset) ? $conf['offset'] : $pv->offset;

   $stored_feeds = drupal_add_feed();
+
+  //PATCH: Adds alter hook for customizing views before rendering.
+  foreach (module_implements('panels_views_alter') as $module) {
+    $function = $module .'_panels_views_alter';
+    $function(&$view, $panel_args, $contexts, $pv);
+  }
+
   $block->content = views_build_view($pv->view_type, $view, $args, $pager_id, $
nodes_per_page, 0, $offset);

   if (($pv->allow_feed_icons && !empty($conf['feed_icons'])) ||
CommentFileSizeAuthor
panels_views.module.patch738 bytesjon pugh

Comments

merlinofchaos’s picture

I'm sorry, you didn't explain why hook_views_alter itself isn't sufficient.

sdboyer’s picture

Status: Needs review » Closed (won't fix)

Sorry, but we need to keep things with Panels moving. Unless I hear back on this in the next couple days, I'm going to won't fix it, as I also don't see any reason why hook_views_alter() isn't sufficient.

Also, no need to include comments in the patch itself indicating that it's a patch.

sdboyer’s picture

Status: Closed (won't fix) » Needs work

Sorry, but we need to keep things with Panels moving. Unless I hear back on this in the next couple days, I'm going to won't fix it, as I also don't see any reason why hook_views_alter() isn't sufficient.

Also, no need to include comments in the patch itself indicating that it's a patch.

sun’s picture

Status: Needs work » Closed (won't fix)