In my module i create view programmatically in such fasion:
$future_matches_view = views_create_view('our_player_future_matches', 'All future matches for the player');
views_view_add_page($future_matches_view, t('Future matches'), NULL, 'table', true, 10, '', 1, false);
views_view_add_filter($future_matches_view, 'node', 'nid', 'views_handler_operator_or', $future_matches, 'id');
views_view_add_field($future_matches_view, 'node', 'title', '', FALSE, 0, 'views_handler_field_nodelink');
views_load_cache();
views_sanitize_view($future_matches_view);
$output .= views_build_view('embed', $future_matches_view, array(), false, false);
As you see i added filter, provided by viewsphpfilter module and passed to it variable $future_matches(i have a snippet to count it) and i also added field node title and everything works just fine. But also i need to add more fields to this table view, such as date-i have a CCK field date and two fields each one for competitor, who will take part in the match- i have CCK fields for competitors(nodereferance, as they are nodes-"bio" module).
So i need to add more views_view_add_field(), but can't figure out parameters which to pass(table, field and handlers).
Any help is appreciated.

Comments

netbear’s picture

I was wrong-
views_view_add_filter($future_matches_view, 'node', 'nid', 'views_handler_operator_or', $future_matches, 'id');
this filter doesn't work too!
Though in another place i created view with something like that:
views_view_add_filter($another_view, 'node', 'type', '=', 'TYPE', '');
and everything worked fine.
Why it doesn't work now and how to workaround this?

merlinofchaos’s picture

Status: Active » Closed (won't fix)

These functions are meant to create views during the import phase, i.e from hook_views_default_views(). They were never intended to add items to a view dynamically. Views doesn't currently have any official support for this behavior.

netbear’s picture

Thanks for the answer, merlinofchaos!
Here is the article which i tried to reproduce:
http://awebfactory.com.ar/node/320
In what direction should i go now to solve my problem?