I have a view that looks like such:
stations/$arg
So if I pass stations/de it shows all stations located in Germany
However for anything that is in the us I want to add a field of city where I don't want that for other locations (right now)
So I figure from reading the best way to do this is to add some Argument Handling code.
I export the code so I can see what is going into $view->field and get this:
$view->field = array (
array (
'tablename' => 'node',
'field' => 'title',
'label' => 'Channel',
'handler' => 'views_handler_field_nodelink',
'options' => 'link',
),
array (
'tablename' => 'location',
'field' => 'country',
'label' => 'Country',
'options' => 'link',
),
array (
'tablename' => 'location',
'field' => 'city',
'label' => 'City',
),
array (
'tablename' => 'term_node_1',
'field' => 'name',
'label' => 'Genre',
'options' => 'link',
),
array (
'tablename' => 'video',
'field' => 'play_counter',
'label' => 'Views',
),
);
And this is what I put into the Argument code
if ($args[0]== "us") {
$view->field = array (
array (
'tablename' => 'node',
'field' => 'title',
'label' => 'Channel',
'handler' => 'views_handler_field_nodelink',
'options' => 'link',
),
array (
'tablename' => 'location',
'field' => 'city',
'label' => 'City',
),
array (
'tablename' => 'term_node_1',
'field' => 'name',
'label' => 'Genre',
'options' => 'link',
),
array (
'tablename' => 'video',
'field' => 'play_counter',
'label' => 'Views',
),
);
}
this produces an error:
user warning: Unknown column 'term_node_1.name' in 'field list' query: SELECT node.nid, location.country, node.title AS node_title, node.sticky AS node_sticky, node.created AS node_created_created, node.title, location.city, term_node_1.name, video.play_counter FROM node node LEFT JOIN location location ON node.vid = location.eid LEFT JOIN term_node term_node_1 ON node.nid = term_node_1.nid LEFT JOIN video video ON node.vid = video.vid WHERE (node.status = '1') AND (node.type IN ('video')) AND (location.country = 'us') ORDER BY node_title ASC, node_sticky DESC, node_created_created DESC LIMIT 0, 20
Is there a better way to get the desired output such that when the url is stations/us that I can add the city field
Comments
Comment #1
sunSorry, unfortunately this support request is way too specific. Please have a look at the issue queue - Views maintainers are buried already. You might want to try to get further support at http://drupal.org/support.
If you were able to solve this issue on your own in the meantime, you might want to add the involved steps to this closed issue, so other users searching for a similar solution might find it.