Posted by shamlah on January 20, 2010 at 1:01pm
Hi Drupalers,
I have a project where lots of images are posted on based of country, on click of the country name, the photos from the particular country should be shown in jcarousel view... Now the problem is i have more than 70 countries, its hard to create 70 separate views, is there any thing like the placeholder where we can write the sql query and get the particular countries view page???
Thanks in advance
Shamlah

Comments
This was the very first real
This was the very first real problem I ran into when i started using drupal.
The solution however, is very elegant.
I'm assuming:
You are using taxonomy on image nodes.
You are using taxonomy on your country nodes.
The solution is to use an argument in your view called 'Taxonomy: Term ID (with depth). (Don't bother using taxonomy term name as argument, or taxonomy term id without dept, they make no sense, at least, not to me).
When adding the argument click on "Provide default argument" and then click on 'PHP code".
Paste the following code:
// Pick up the taxonomy for the node in focus
$node = node_load(arg(1));
if ($node && $node->taxonomy) {
$terms = array();
foreach($node->taxonomy as $term)
if($term->vid != 1) {
$terms[] = $term->tid;
}
if($terms) {
return implode('+',$terms);
}
}
return arg(2);
}
This also works on views on the corresponding taxonomy pages!
(Be sure to set the "depth" dropdown box to a relevant value if you are using hierarchical vocabulary)
Kind regards,
izz ad-Din Ruhulessin
thanks a lot
Let me try and, let u know...
thanks for ur reply