Hello,

I have created a view called 'calendar'. I want to change the items_per_page value of the 'upcoming' block programmatically. So I execute the following code in a test module:

$view = views_get_view('calendar', TRUE);
$view->set_display('upcoming');
$view->init_pager();

$view->set_items_per_page('50');

$view->save();

The update is made but the change is not saved. It seems that $view->save() doesn't really save the view.

What could be the problem in this case? Is something missing/wrong in the code? What would be the proper way to achieve the desired functionality?

Thank you,

- nikos

Comments

sebto’s picture

I haven't created a view programmatically. You can create views by "hook_views_default_views".
To update views, try this link. It may help you.

Hariram S’s picture

$view->save() wont save the view which already exists. It will look for the vid.
If you want to change the pager you can do it by configuration changes or i think changing the db value will do.. I am not sure with it.