I have a view with exposed filters - created a new panel page with this view as content - when I execute an exposed filter - the tab disappears (all tabs) and the result of the view is visible.

Is there a way that the tabs remains - to be more specific - all tabs remain when executing a view with exposed filters.

Because now, after executing the view you are lost, because no more tabs (e.g. homepage of group).

CommentFileSizeAuthor
#4 Neu Textdokument.txt8.63 KBbaff

Comments

jimthunderbird’s picture

Hi Baff,
Could you export your views so I can test it?
Thanks.

Best Regards,
Jim

jimthunderbird’s picture

Hi Baff,
I have figured out what happened. Basically after you submit the views exposed form, the form's action is / which leads to urls like:
/?nid_op=%3D&nid[value]=1&nid[min]=&nid[max]=
This type of url will cause the tab to loose effects, we need something like /node/1?nid_op=%3D&nid[value]=1&nid[min]=&nid[max]=
The following is a hook_form_alter type fix to it.

function og_panels_form_alter(&$form, $form_state, $form_id){
    if($form_id == 'views_exposed_form'){
      if(arg(0) == 'node' && arg(1) > 0){
        $form['#action'] = url("node/".arg(1));
      }
    }
}

Best Regards,
Jim

baff’s picture

Hallo jimthunderbird, wow you are fast!

Should I put function og_panels_form_alter into og_panels.module until a new version is there?

PS: You don't need my exported view anymore as you found out already?

baff’s picture

StatusFileSize
new8.63 KB

I have made the patch like that in og_panels.module:

/**
* Implementation of hook_form_alter
* attach og_panels_export_import_form before the panel edit form
*/
function og_panels_form_alter(&$form, $form_state, $form_id){
if($form_id == 'panels_edit_display_form' && arg(0) == 'node' && arg(1) > 0 && arg(2) == 'og_panels' && arg(3) > 0){
if(user_access('import and export OG panels pages')){
$did = (int)arg(3);
$form['#prefix'] = drupal_get_form('og_panels_export_import_form', $did);
}
}
/**
* patch
*/
if($form_id == 'views_exposed_form'){
if(arg(0) == 'node' && arg(1) > 0){
$form['#action'] = url("node/".arg(1));
}
}
/**
* patch ende
*/
}

The rsult is: I can sse my view with exposed filters and tabs. When executing the filter I come to the group homepage, but not the result of my view.

My view attached, very simple one - just for testing

jimthunderbird’s picture

Hi baff,
Thanks for posting the view. Honestly, When using views exposed filter in og panels page, as you observed, though the tabs and filter form works, the result will not be displayed. I was thinking about a possible solution here, but it's more of a "developer oriented" solution.

If you analyse the url that's generated when you post the views exposed filter form, it will have some request variables like type=***, with that, you can create a new custom content in your og panels page, inside you can use views_get_view function in views module and pass the arguments in.

So in the body of your new custom content, you can use php as input filter, then call views_get_view with your views name, then pass the arguments from the url as the arguments to the view.

For your reference, there is a post talking about how to embed a view here:
http://drupal.org/node/246742


It boiled down to using 2 apis:
$view = views_get_view($name);
print $view->preview($display_id, $args);

Using views_embed_view api will be good enough.
Here's a link on how to use it:
http://www.wootenswebdesign.com/viewsembedview-usage

Also, my previous patch does not cover this use case:
If you put your exposed filter on other og panels except the homepage one, my previous form alter solution is not good enough, here is a solution covering this case:

   if($form_id == 'views_exposed_form'){
      if(arg(0) == 'node' && arg(1) > 0){
        $form['#action'] = url($_GET['q']);
      }
    }
   

Hope this helps.

Best Regards,
Jim

jimthunderbird’s picture

A quick update:

I've make the exposed filter work, I will describe the process and hope it gave you some hints:

1. I first modify og_panels module, as mentioned before, using hook_form_alter

function og_panels_form_alter(&$form, $form_state, $form_id){
    if($form_id == 'views_exposed_form'){
      if(arg(0) == 'node' && arg(1) > 0){
        $form['#action'] = url($_GET['q']);
      }
    }
}

2. I created 4 content types in my testing drupal site, "community", "community_post", "story", "page"

3. I created a view named "dummy_node_type_filter", use Node:type as argument and then exposed the node type and make the filtering form display as a block.

4. I then create a new og panels page, place the exposed filtering form in it.

5. I then created a new custom content underneath the exploded filter form, inside I put the following php code

<?php
print views_embed_view('dummy_node_type_filter', 'default', trim($_GET['type']) );
?>

Basically what it does is look for the type variable in the request variables and then pass it to my view.

Save all the works and now it works great.

Hope this help on your way of site development.

Best Regards,
Jim

jimthunderbird’s picture

Status: Active » Needs review

Commited!