I am using Views contextual filter to get node id. It is given as query parameter "?applicationID=1319". Now I have found no way how to delegate that url parameter to a view with quick tabs. I have tried %0/%1/%2/applicationId, but none of these seem to work.

Does the quick tabs for D8 support this feature? Block tabs module works well out-of-the-box, but it seems that Quick tabs would be better module for future support.

Comments

ErnoVanhala created an issue. See original summary.

sachand’s picture

I have fixed this issue , it seems that its missed whie porting to D8 Version . working on patch will upload here soon.

sachand’s picture

Here is the patch that resolves the issue of argument passing to quicktabs and directly loading particular tab from the url.
to load particular tab use qt-quicktab instance name= tab number (e.g. www.mysite.com/?qt-mytab=1).

sachand’s picture

Status: Active » Needs review

Status: Needs review » Needs work
sachand’s picture

StatusFileSize
new4.36 KB
sachand’s picture

sachand’s picture

ErnoVanhala’s picture

My original problem was not the "active tab", but the argument to views. But it was already fixed earlier.

Then again this was another problem and this patch seems to fix "go directly to a specific tab", so thank you for that!

andkar’s picture

StatusFileSize
new3.74 KB

When I load a view with ajax that uses argument the patch #7 doesn't work. The reason is that current path is the path of the ajax route and we can’t use that for extracting the arguments we need. I have modified the patch to use $_SERVER[’HTTP_REFERER'] to get the arguments when ajax is used.

oeklesund’s picture

StatusFileSize
new3.97 KB

Improved the patch #10 to strip language prefixes in the url, allowing the use of the same offset with or without that language prefix.

$current_language = \Drupal::service('language_manager')->getCurrentLanguage()->getId();
$path = str_replace("/$current_language/", '/', $HTTP_REFERER['path']);
oeklesund’s picture

StatusFileSize
new3.95 KB

Fixing typo.

oeklesund’s picture

marassa’s picture

The patch works fine, but the first argument, like '333' in '/node/333' is matched to %2, because %0 is '' and %1 is 'node'. This is confusing and totally impossible to figure out from the docs until you look in the code and see the
$url_args = explode('/', $current_path);
Is it by design? Are there any real-life situations where the argument does not follow '/node/' or '/user/' or whatever, so that we can't just drop the first two elements?

scottsawyer’s picture

This patch works great, thank you. Can we mark it RTBC?

lnunesbr’s picture

Status: Needs work » Reviewed & tested by the community

Patch #12 works just fine.

manuel garcia’s picture

+++ b/src/Plugin/TabType/ViewContent.php
@@ -73,6 +73,22 @@ class ViewContent extends TabTypeBase {
+        $HTTP_REFERER =  parse_url($_SERVER['HTTP_REFERER']);

Should we be using \Drupal::request()->server->get('HTTP_REFERER') instead?

shelane’s picture

StatusFileSize
new5.78 KB
new2.93 KB

I have rerolled the patch with the request service.

Since there are no tests covering this, I would appreciate anyone being able to test it against with their use cases.

shelane’s picture

Status: Reviewed & tested by the community » Needs review
manuel garcia’s picture

Status: Needs review » Needs work

Thank you @shelane for pushing this forward.

I wanted to note that any class extending ViewContent would have to be updated with this change, but I doubt anyone is doing so.

@@ -77,10 +102,13 @@ class ViewContent extends TabTypeBase {
       $current_path = \Drupal::service('path.current')->getPath();
       // If the request is a ajax callback we need to use $_SERVER['HTTP_REFERER'] to get current path.
       if (strpos($current_path, '/quicktabs/ajax/') !== FALSE) {
-        $HTTP_REFERER =  parse_url($_SERVER['HTTP_REFERER']);
+        $request = $this->requestStack->getCurrentRequest();
+        if ($request->server->get('HTTP_REFERER')) {
+          $referer = $request->server->get('HTTP_REFERER');
+        }
         // Stripping the language path prefix.
         $current_language = \Drupal::service('language_manager')->getCurrentLanguage()->getId();
-        $path = str_replace("/$current_language/", '/', $HTTP_REFERER['path']);
+        $path = str_replace("/$current_language/", '/', $referer);
         $current_path = \Drupal::service('path.alias_manager')->getPathByAlias($path);
       }
       $url_args = explode('/', $current_path);

Looks to me that it could be that $referer is not set which would result in a PHP Notice.

shelane’s picture

Ah yes. I meant to put a check in later for isset. Nice catch. I’ll update the patch shortly.

shelane’s picture

Here is a better refactor of that.

shelane’s picture

Status: Needs work » Needs review
shelane’s picture

Status: Needs review » Needs work
scottsawyer’s picture

Patch in #22 does not apply to dev-3.x e8cae4a. Not sure why yet.

shelane’s picture

There have been significant code code changes with more to come. So, this is on my list to come back to after I get some other major issues fixed.

shelane’s picture

Issue tags: +Global2020
loze’s picture

StatusFileSize
new3.25 KB

The patch didn't quite work for me without a few tweaks.
Here is what I had to do to get views tabs working with arguments.

loze’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 28: views-tabs-arguments-2873253-28.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

shelane’s picture

Patch at 28 ignores all the changes for dependency injection from the previous patch. I'm going to have to manually review the differences.

loze’s picture

Yea, I couldn't get the dependency injection working. That's where it was failing for me and no matter what I tried I couldn't get the dependencies to be available in the class. I'm probably overlooking something simple, as I'm still trying to wrap my head around how that all works in D8.

shelane’s picture

Patch 28 needs more work. When there is no QuickTabs yet created, this error is generated on the /admin/structure/quicktabs/add page:

Notice: Undefined index: type in Drupal\quicktabs\Plugin\TabType\ViewContent->optionsForm() (line 30 of modules/custom/quicktabs/src/Plugin/TabType/ViewContent.php).

loze’s picture

StatusFileSize
new2.28 KB

This is what got views arguments working properly for me.

loze’s picture

Status: Needs work » Needs review

  • shelane committed b499e9c on 8.x-3.x authored by loze
    Issue #2873253 by sachand, shelane, loze, becassin, ErnoVanhala,...
shelane’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.