By darklight on
Hey guys.
I am well and truly stuck here. I feel this should be a simple script but nothing I write works in any way like it should. I am trying to create a Views Block which will show related content by using an argument to get nodes from the same term as the node currently being viewed. Here's the code I am using...
$node=node_load(arg(1));
if($node){
foreach($node->taxonomy as $term){$terms[]=$term->tid;}
return implode('+',$terms);
}else {return;}
And it works perfect, but what I wish to do is make that code select a specific vocabulary, e,g. the one with ID "12"
Simple enough? I've been working on this all day and am now stuck. I'll be grateful for any info you can provide.
Thanks in advance.
Comments
Hello, perhaps help
Hello,
perhaps help this
foreach($node->taxonomy as $term){
if ($term->vid == 12) {
$terms[]=$term->tid;
}
}
the vid is the id from parent vocabulary
Hi there. I already tried
Hi there.
I already tried this sort of thing. Nevertheless I tried it again, and regardless of how I re-work it, I still don't get what I want. I tried using bits out of this code to merge with my current code and still no good.
Surely this is not impossible to do.
I simply want to return nodes "with the same tags" from WITHIN the "same category". Both using the Taxonomy System.
Thanks.
Fixed It!!
Hey guys. Nevermind, I fixed it! I am using two Arguments both with "work together" option enabled. In one I have the PHP:
and in the other I have:
These work perfect. Although, any upgrades are welcomed, e.g. Merging all of this into just one argument.