Can you provide an example of how to pass an argument from the url or parent NID to the view?

Comments

danielb’s picture

you can access url arguments with arg(0) arg(1) arg(2) etc...

so if you are on node with nid 22, your path is node/22 (we can ignore aliases and stuff)

something like this can be used to find out the node id

<?php
if (arg(0) == 'node' && is_numeric(arg(1))) {
  print arg(1);
}
?>

I've never tried it - but you may be able to access $node->nid directly without the arg stuff - give it a try.

break9’s picture

Thanks, that is helpful. could you possibly shed some light on the following scenario.

I have a contenttype called 'company' within that node type there is an embedded view that displays the nodehierarchy children of that 'company' which are contentype 'cases'. So you have a 'company' with an embedded view that shows a list of 3 (could be more or less depending on how many cases are assigned to that company) 'cases'. Each 'case' has a viewreference field that displays all of the 'cases' nodeheirarchy descendants that are content type 'articles'.

It looks like this

company example
company example embedded view{
--case 1
----case cck view reference field (test){
------article 1
------article 2
----}
--case 2
----case cck view reference field (test){
------article 1
--------sub article 1
------article 2
----}
--case 3
----case cck view reference field (test){
------article 1
--------sub article 1
------article 2
------article 3
------article 4
----}
}

the cck view reference field uses the same view each tim to produce the 'cases' descendants. This brings me to the issue....How do i structure the argument in the cck view field to pull the NID from the 'case' that is being generated from the embedded view of the 'company' instead of the top level 'company' node on which this all sits. I can return the args and NID of the node or 'company' nid that all of the display is being generated from but i don't know how to get the nid of the nodes that are being generated by the emedded view. I need each 'case' nid to be used as an arg in the view reference cck field so that the content display in that view is dynamic and related to each case only.

Any help is appreciated. I'm sure that is probably very confusing.

danielb’s picture

Status: Active » Fixed

The question you have is not really related to this module. I can only tell you how to put the argument in after you already know how to get it. If you need to pull those arguments out of other modules - then perhaps you should ask the maintainers of those modules?

break9’s picture

I figured out a way to accomplish this through by using the view reference default value in the admin settings. Is there a way to incorporate the tokens module or another existing value that would automatically assign the NID from the new node created to be the default argument for the view reference field?

Status: Fixed » Closed (fixed)

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

jvieille’s picture

Status: Closed (fixed) » Active

I really can't get it.

How to practically send the current nid as the default argument to the selected views?

in Viewfield, it just need to type %nid in a default argument field which does not seem to be available here.

Andrés Chandía’s picture

Version: 6.x-2.8 » 7.x-3.x-dev
Component: Code » User interface
Priority: Normal » Major

Hi, I think I'm a little confused about what exactly I'm looking for, maybe your module is a kind of solution for me, but as I tell I'm a little lost, I've been looking for help through these issues: https://drupal.org/node/1929030 and https://drupal.org/node/1928064, so if you were so kind to read them and advice me on how to proceed or what to look for, I would be really thankful.

danielb’s picture

Version: 7.x-3.x-dev » 6.x-2.8
Component: User interface » Code
Priority: Major » Normal
Issue summary: View changes

If you need to change all of the settings on an issue - maybe that's not the right issue for you

danielb’s picture

Status: Active » Closed (fixed)