QT should support the %N format as the view argument grabbed from the url.

quote from the panels module:

Additional arguments to send to the view as if they were part of the URL in the form of arg1/arg2/arg3. You may use %0, %1, ..., %N to grab arguments from the URL.

Comments

Flying Drupalist’s picture

Oh subscribe. Probably the most important thing for me right now.

I anticipate this hugely.

pasqualle’s picture

little guide toward the solution, extracted from the panels_views_all_views_render() (panels_views.module)

  $arguments = explode('/', $_GET['q']);
  $args = $conf['args'];

  foreach ($arguments as $id => $arg) {
    $args = str_replace("%$id", $arg, $args);
  }

  ...

  $args = preg_replace(',/?(%\d|@\d),', '', $args);
  $args = $args ? explode('/', $args) : array(); 

  ...
  $view->set_arguments($args);
pingers’s picture

Status: Active » Needs review
StatusFileSize
new1.42 KB

Hopefully I did this right...

This small patch should add this much needed and easy to implement feature :)

Please try it. (See http://drupal.org/patch if you need to learn how to apply it)

Thanks

summit’s picture

Subscribing, greetings, Martijn

pasqualle’s picture

Status: Needs review » Needs work

It works but

1. using '%' sign in the view argument makes invalid HTML for the quicktab as it is used for the link id (to load ajax content)

<a id="view--2--0--cars--block_1--%1"

Warning: <a> attribute "id" has invalid value "view--2--0--cars--block_1--%1"

I don't have a good solution for this. Maybe we can use Drupal.settings.quicktabs to pass settings to quicktabs.js (instead of adding it to the link) but it requires a quite large rewrite of the source code.

2. I think the input should be sanitized. check_plain() on arg() or something.. But I am not sure about this.
I would prefer to have the same code as Panels have for displaying the view, and a confirmation that the arg handling is safe (as I do not see where it is sanitized in Panels)

pingers’s picture

StatusFileSize
new1.86 KB

Doh... that's not good.
Here's an update.

pasqualle’s picture

I think with the new patch views inside ajax quicktabs does not handle args from url
but you are getting close to the solution :)

pingers’s picture

Nothing changed in the argument handling code part - only the addition of str_replace for '%' with 'arg'.
Maybe try downloading the module fresh and applying the patch again.
I can confirm argument handling is still working for me.

pasqualle’s picture

ok, I tested it now. I can tell it does not even worked with the previous patch.

the problem is that the quicktabs.js needs that value what you have changed in the last patch. There must be the exact argument value for that view, otherwise it can't work with an ajax quicktab..

if you put the view on the first tabpage than it will work, as the first tabpage in not an ajax tabpage, it is loaded at page load. Try to move the view to the second tabpage and you will notice that the view does not receive the arg from url..

pingers’s picture

Ah, I wasn't using ajax.

Ok, the solution would be to set a js variable - rather than hacking it out of a css id.
No mucking about that way - I'll fix this when I get a chance.
Cheers!

pingers’s picture

StatusFileSize
new3.47 KB

Well, turns out the js variable was already being set, so I don't know why it wasn't being used over hacking it out of a css id. Eeeek.

Anyway... please try it out.

PS. There was another bug where extra slashes were getting added to the view variable (due to not being emptied for each tab).

Cheers

pasqualle’s picture

Status: Needs work » Needs review

the last patch is strikingly interesting...

I have some questions, as I see you must be quite familiar with Drupal ajax handling:
1. why tab.qtid?
var args = Drupal.settings.views.ajaxViews[tab.qtid].view_args;
I tried to find where is it set in the module, but I can't find a connection. In the _quicktabs_prepare_views() function the qtid is not used.

2. How do you check the values in Drupal.settings? Is it possible with firebug?

pingers’s picture

1. I figured the tab.qtid was the id of the quicktab. (The order in which they appear). If this is incorrect, my apologies.
I'll have to setup a few more tab pages and test more thoroughly... to ensure this is the right variable.

2. Firebug :) Unfortunately you can't see the globals unless you reference them. (not a problem in this case)

How did it work for you?

quioxte’s picture

seems to be working fine here. thank you thank you and thank you.

mr.andrey’s picture

I just tested this on a tracker view as a second tab. It picks up the argument correctly and displays tracker for the proper user as tracker/uid would.

Great work!

Best,
Andrey.

katbailey’s picture

StatusFileSize
new4.38 KB

Hmm, the method for getting the correct view args from Drupal.settings was not reliable. I have reworked the patch to add the evaluated url args onto the id string of the tab element. It's working for me but I'm aware that different people have different use cases so wanted to throw this up and see if it works for everyone else before committing.

pasqualle’s picture

I am not sure, but the last patch seems like a possible security hole, as it puts a parameter from url directly into the HTML output within the _quicktabs_construct_tab_attributes() function..

katbailey’s picture

Ah, never thought of that - good catch. Then I guess we're stuck with passing it through Drupal.settings but it may need to just go in Drupal.settings.quicktabs seeing as there's no reliable way to access the correct ajaxView object from Drupal.settings.views.ajaxViews - even checking against the view name and display id isn't reliable because you could have two instances of that exact same view/display with different arguments.

katbailey’s picture

Status: Needs review » Needs work

Changing the status...

pasqualle’s picture

I would like to see this feature solved in 2.x version, but I am not sure how big the Drupal.settings.quicktabs change would be..

cfmcoder’s picture

subscribing

katbailey’s picture

Status: Needs work » Fixed

OK, since getting tab details into Drupal.settings.quicktabs (per #394400: Use Drupal.settings.quicktabs) we now have a reliable way of getting the correct view arguments. The fix committed in http://drupal.org/cvs?commit=184224 is a reworking of pingers' approach using this more reliable method for the ajax views. Please try out the next dev release (should be created a few hours from now) and let me know if there are any issues with this.

pasqualle’s picture

Status: Fixed » Needs work

small html problem

Warning: <a> attribute "id" has invalid value "1-0"

ID must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

the problematic code inside _quicktabs_construct_link_options() function:
quicktabs.module line 316

$id = implode('-', array($qtid, $tabkey));

I guess the tab link id is not used any more so this code can be removed.

katbailey’s picture

Ah yes, I had got rid of all the other info we'd been putting in there and thought I'd better leave something as I think the element's id is used in the progress-loading js, but forgot there would only be numbers left ;-) I'll add quicktabs-tab- or something to the start of it

pasqualle’s picture

there is something wrong with view argument handling in ajax loaded tabpages.

the view argument setting is: If the argument is not present then display all values. This setting works with non-ajax quicktab, but with ajax quicktab the view is not displayed if the argument is not provided in the url.
Tried with single and multiple arguments also..

katbailey’s picture

Hmm, I'm not sure how to handle this... need to look into it more.

tayzlor’s picture

subscribing

katbailey’s picture

OK, I've committed a change which I think eliminates problems with non-present arguments from the url (http://drupal.org/cvs?commit=185662). However, during testing I did notice a strange bug with views arguments, which I haven't found a fix for but it is extremely edge-casey:
If you have a QT block with the same view in two tabs but with different arguments, if the second tab rather than the first is loaded on page load (e.g. by accessing it directly with ?quicktabs_0=1 or whatever appended to the path) and it has pager links (ajax-enabled of course), then the pager links mistakenly call the view with the arguments for first tab. However, this second view works perfectly fine if it is loaded via ajax, as it would be under normal circumstances. It also works fine if the QT block is set to non-ajax mode.

Otherwise, I think the arguments are working properly. Please test.

pasqualle’s picture

the current argument handling was not able to process this type of argument:

%1+myterm+%2

it could be a valid list of taxonomy term arguments for the view.

So I replaced the argument handling code with the one used in panels 3, and also replaced the ugly view rendering code:

$output = call_user_func_array('views_embed_view', $func_args)

http://drupal.org/cvs?commit=186444

this still needs testing..

pasqualle’s picture

fixed #24 http://drupal.org/cvs?commit=186452
We should simplify the markup when we move to theme templates..

pasqualle’s picture

It seems the only remaining issue here is #25. I need to retest that..

virtualdrupal’s picture

I'm experiencing the same problem as #25 with the latest Dev of 6.12 x 2.x

I have three tabs, all views blocks that depend on the arg(2); of the taxonomy url to populate the blocks.. Only the 1st tab works, I can't ajax load the other tabs, if I ditch the ajax mode all three tabs populate fine. From what I gather none of the above patches would solve this right, it's next on the list?

pasqualle’s picture

no there is no patch for #25

giorgio79’s picture

subs
slightly similar as #25

but with ajax quicktab the view is not displayed if the argument is not provided in the url.
Tried with single and multiple arguments also..

For me only the first tab loads, the rest do not, even if I have the argument in the URL!
This is on plain taxonomy pages, overriden with views. I would show a QT block, but only the first tab loads, even if I pass arg(2) to the block.

pasqualle’s picture

@giorgio79: please create a new issue, because the taxonomy argument should would.

giorgio79’s picture

Thanks Pasqualle. Meanwhile I solved my issue at #34. For the second tab I had to pass an argument, but only %2 worked for a taxonomy term ajax quicktab, arg2 or arg1 did not. Thought I post it here now that I solved it instead of a new one.

Flying Drupalist’s picture

In my view I have the default arg set as this:

$node = node_load(arg(1) );
  $title = str_replace(' ', '-', strtolower($node->title) );
  return $title;

With a relationship of node-reference.

Nothing gets returned on ajax tabs. I think it's part of this issue.

What is this status on here?

Is more information needed or testing needed or something?

Thanks everyone.

pasqualle’s picture

@Flying Drupalist: this issue is mostly fixed. View args from url works.
But your problem does not seem related, as you are using a default arg, not an arg from url..

crea’s picture

Subscribing

whikloj’s picture

subscribing

webwriter’s picture

Sorry to bump this, but it says fixed... I just downloaded QT today and if I test my QT block as a normal block, %1 works fine for the arguments in my views. However, including that block in a panel returns no content.

Is that a different issue, or related to this one?

pasqualle’s picture

However, including that block in a panel returns no content.

yes, different issue. Panels argument handling not supported (yet).

wjaspers’s picture

In response to #41:

I'm getting a similar result in Views blocks that make up my QuickTabs block.
I'm using Context to add the Quicktabs block to the page (which is working).
The end result is a set of QuickTabs with no contents!

pasqualle’s picture

BeaPower’s picture

Im having the same problem, so panels arent supported at all?

BeaPower’s picture

Im having the same problem, so panels arent supported at all?

madjr’s picture

subscribing

also looking for a fix for issue #25

-------
edit:
fixed my issue here :)
#921264: Quicktabs NID to View

a note stating that
"ajax mode may need additional arguments (%N) to pass them from URL to QT to views"
would had been nice :)

notslad’s picture

NOTE: This problem seems to carry over into the D7 version. Let me know if I should create a new ticket instead.

Same problem here but with 7.x-3.0. I have a view that takes three arguments. QuickTabs needs to supply %1 and %2 arguments from the URL and the third argument is provided on a per tab basis (eg. "%0/%1/lesson-type1" or "%0/%1/lesson-type2").

If I manually specify the views arguments the correct entries for the "Block" version of the view are displayed. If I replace any of those arguments with a %N the view returns no results and I occasionally get the following error in my logs..

Warning: implode(): Invalid arguments passed in form_error() (line 1593 of /srv/www/htdocs/drupal-7.4/includes/form.inc).

bmx269’s picture

Version: 6.x-2.x-dev » 6.x-3.0

Either I am having a brain fart, or I am having issues. Prob the last part. I am trying to pass arguments to views, as follows.

From the Taxonomy term page url - http://example.com/toyota/ae86-corolla

from the quicktab - %0/%1/engine

the view is built so that it will read /toyota/ae86-corolla/engine and output content, as the chassis and section are 2 separate vocabularies. I am not sure why I am not getting the results, or how to check if the argument is being passed correctly. Any help is awesome as I am struggling with this. Thanks.

pingers’s picture

Version: 6.x-3.0 » 6.x-2.x-dev

Hi bmx269,

What you're asking for is a support request. Please create a new issue for your needs. This issue relates to the creation of the argument handling in the previous version. Resetting version...

Thanks.

netw3rker’s picture

Issue summary: View changes
Status: Needs work » Closed (fixed)