I have a challenge and am pulling out my hair. I am not a coder and am just starting to learn how to set and pass variables. I am told on the IRC that I have the right solution but it isn't working for me. Here is the situation.

I am using [term-raw] to create a path with pathauto. This gives me a URL of http://example.com/term1/title-of-page. I have a content type called image where I use the imagefield to upload an image. I use the same taxonomy vocabulary in the image content type as I do in the story content type so each node gets assigned the same term (the image for term1 is assigned the term1 and the content associated with term1 is assigned term1). They have an indirect relationship. I am logged in as admin1 so permissions should not be an issue.

I created a view block, assigned the block to a sidebar region. The view is setup as follows:

- view filter is content type image
- view field is the image that I uploaded
- view argument is taxonomy:term

the argument settings are:
- action is "provide default argument"
- default argument type is php code
- the code is:

$variable = arg(1);  
return $variable;

Testing the view using the preview pane shows the view working. I can enter the term and it shows the correct image. So, I am assuming that for some reason, the view is not getting the argument from the URL. I have tried numerous view configurations to get this to work. I even tried setting a fixed entry with every variable call I can imagine but it didnt work (arg(1), %arg(1), arg[1], etc.)

Thoughts as to why it works for someone on IRC and not me?
thank you in advance
cindy

Comments

idcm’s picture

I had an ah-ha moment. I am guessing the issue has to do with the alias url that pathauto is creating. I am trying to capture the alias information, note the real url - dah.

I am trying the code in this post but it isn't working: http://drupal.org/node/503184

idcm’s picture

I got it!

I was originally trying to pass the term so my view argument was set to term. I forgot to switch to TID as the argument.

dah!

dhalgren’s picture

i have 3 custom content type:
- comment, with integer field "select image" ad noderefrence field "object".
- object, with nodereference field "image" (multiple choice) and NODEREFERRER field to "comm"
- image (where I use the imagefield to upload an image).

now, i'm trying to connect the object to multiple image and the comment to the object.

I am using a view to select an object and create an URL of
"http://example.com/node-id-object/select_image"

i've set another view, that must show (in four block):
-the image selected via comment
-all the images tied to an object
-the id of the object
-the field "select image"

this second view need arguments
but i don't know ouw to write the php
for grabbing the "select image" value from the url.

idcm’s picture

I am sorry but I dont follow all you said. I am not a coder and was lucky to find that someone had done the code already. Hopefully someone else in the community can help.

andrew_hoffi’s picture

Hi Cindy,
Not sure if your still going to pick this up, but worth a try. I'm working on a site that requires me to pull a block inside a node and filter the results in the block based on a term in the URL. I'm using the code you suggested in your first post as I'm not using clean URLs for this section of the site. The url is passing ?q=nodetype/term, but no matter whats arg(???) I try it only returns the name of the nodetype.

Any ideas?

Thanks
Andrew
-------------------
www.hoffi.com

idcm’s picture

It's hard to tell what the issue is. Are having difficulty showing the block view in the node? Are you not pleased that only "nodetype" is showing in the view result?

As for the code in the original post, I ended up using this found on http://drupal.org/node/503184. At first I didn't think it would work but it was my error.

$node=node_load(arg(1));
if($node->taxonomy){
  foreach($node->taxonomy as $term){
    if ($term->vid == 2) {
      $terms[]=$term->tid;
    }
  }
}
if ($terms) { return implode('+',$terms); }