Posted by jdidelet on October 7, 2009 at 4:10am
Hi all,
Anyone can help me ? I have a problem in Views 2 with PHP argument code (well, I probably a problem with my code). I push this code but it's seem wrong and I don't understand why (I choose Taxonomy: Term ID (with depth) for argument) :
if (arg(0) == 'products') {
$arg_array = arg();
$value = end($arg_array);
}
return $value;
Probably I miss somethings.
Regards,
Julien
PS : My URL is like that : name-of-my-site.dev/products/taxonomy-name1/taxonomy-name2/...

Comments
Hi Julien, You shouldn't need
Hi Julien,
You shouldn't need any PHP to setup a view with arguments. What is it that you are trying to do?
--
Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his
Ok, I have a taxonomy tree
Ok, I have a taxonomy tree like that (for exemple products taxonomy) :
level1
--level1.1
----level1.1.1
level2
...
I use vocabulary index to generate a browsable navigation for my products taxonomy (on URL : my-website.dev/products).
In my pathauto taxonomy term path, I set products/[catpath-raw].
On my my-website.dev/products/level1 page, I want publish a block with all nodes who have level1, level1.1 or level 1.1.1 values(all child values) below the vocabulary browsable index.
If I'm on my-website.dev/products/levle1/level1 .1, I'll publish only nodes with level1.1 or level1.1.1 values. For that, I want to create this block with views.
I parameter this block with "Taxonomy: Term ID (with depth)" argument. But I need to add some php code in "PHP argument code: " to personalize my argument (I want just the last value of my url).
Julien Didelet
Founder
Weblaa.com
Two things come to mind.
Two things come to mind. First arg() returns the internal Drupal path, not an alias, so it might return something like "products/[term_id]". You might instead look at drupal_request_uri() instead:
http://api.drupal.org/api/function/request_uri/6
Secondly a taxonomy argument can be configured in many different ways. It can either accept an ID, or the term name. Make sure you are using the right one given the data that you have.
Also if you aren't using the devel module go install that first. It makes for really easy debugging. Just put a dpm($variable); anywhere you are confused about what the value of something might be.
--
Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his
Oh yes you're right. I forgot
Oh yes you're right. I forgot this. arg() doesn't work with alias... It's probably that.
Thanks for your help !
Julien
Julien Didelet
Founder
Weblaa.com