Hi guys,

I'm trying to create a view dynamically in my theme's file it looks like it works ok, except one thing. View is returning to many items. I need only 9 of them but as a result I'm getting all of them.

//Create a basic view object.
$view = views_create_view('catalog_items_home', 'This is a test view');							 
//Now add a page "view" to the view (teasers, pager on and 5 nodes-a-page)
views_view_add_page($view, 'title', NULL, 'teaser', true, 9, '', 1, false);								 
//Add a filter for the type we want (eg, blog)
views_view_add_filter($view, 'node', 'type',   '=', 'catalog', '');								 
//Add a filter so we only get the published status
views_view_add_filter($view, 'node', 'status', '=', 1, '');
								
$t = array();
$t[] = 647;
$t[] = 38;
views_view_add_filter($view, 'term_node', 'tid', 'OR', $t, '');
									
//Invoke the cache (D5 only!)
views_load_cache();									
//Santize it (eg, create field id's, etc)
views_sanitize_view($view);									
print views_build_view('embed', $view, array(), false);

Thank you in advance! I'm fighting 2 days already with no luck :(

Comments

mixey’s picture

Looks like I found a workaround :)

print views_build_view('embed', $view, array(), false, 9);