I'm doing something very simple in the ajax header:

print arg(1);

This should get me the nid of the node that the qt block is placed on, right? In the QT config I've put %1 as an argument.

For non-ajax tabs I get the nid correctly. For ajax tabs however, I get 'ajax'. What can I do? Thanks.

Comments

pasqualle’s picture

ajax tabs are loaded on the path quicktabs/ajax/node, quicktabs/ajax/block, quicktabs/ajax/qtabs or views/ajax

that is why you get 'ajax' for arg(1). The ajax loaded content does not know what is the original url..

Flying Drupalist’s picture

Is there any way to pass the original url to the ajax tab?

I thought that was what the arguments field in the qt settings were for...

In the other issue you said that "%1 argument format now works in QT." How do I print the original nid?

Thank you.

pasqualle’s picture

the original url values are passed to ajax tab with %0, %1, ...
you can't use arg() in ajax tab.

use for example print $node->nid in node.tpl.php and you can see the nid.

Flying Drupalist’s picture

Is there something else I can use inside an ajax tab or am I totally screwed?

How do I get the value of %0 %1 and so on?

pasqualle’s picture

what are you trying to do exactly?

Flying Drupalist’s picture

I have a view of node referrers to a node. I'm trying to create a link in the views header to add a new node referrer.

Basically the link would look like this:

/node/add/images?field_reference=nid

This autopopulates the reference field with this node, thus creating the referrer.

Usually I can just put arg(1) for nid and be done. What else can I use?

Thanks you so much for putting up with my questions.

pasqualle’s picture

You can't do it in the view header. The view header is not flexible enough in views-6.x-2.x

but you can do it in view template. Just create a theme template for your view and add something like:

<a href="node/add/images?field_reference=<?php print($view->args[0]) ?>">New something</a>
Flying Drupalist’s picture

Do you know if it would be possible to use the header in views 3? Doing something like this in a theme makes maintenance really hard.

pasqualle’s picture

I do not know much about view3, but as I know it has a new handler for header and footer.
Putting php into the database (writing php in the views ui) should not be allowed..

Flying Drupalist’s picture

I wish there was a better way as well. There was some core issue discussing removing eval and such and making an interface for uploading code without storing it in the database, but it hasn't gone anywhere. Right now, being able to edit the view from one interface is worth its weight in gold.

And making views functionality theme dependent would be crazier.

netw3rker’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)