Quantcast
Channel: Running a function before a View executes - Drupal Answers
Viewing all articles
Browse latest Browse all 5

Running a function before a View executes

$
0
0

I have a carousel built using Views (7.x-3.x) that displays 10 items. In this carousel I would like to place 1 item (inclusive of the 10) that displays Twitter content.

What I would like to do is run the function that uses the Twitter API before the View is built/executed. If it succeeds then the View should display 9 items from it's own query (10 items total.) If it fails, then the View would display 10 items from it's own query.

I have successfully implemented the View and the Twitter function running on the theme layer though in order to have a 'fall back' by altering the number of items displayed I would need to do this before the View is built/executed.

Can anyone point me in the right direction for this?

I believe I am looking at the right function "hook_views_query_alter" but I'm not sure how to set "items_per_page"

Thanks


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images