Lucia
Lucia

Reputation: 614

hook_views_pre_execute is not executing

I am trying to modify the query by using the hook_views_pre_execute but I think is not executing at all. Right now my code is the following:

function custom_views_pre_execute(&$view) {
    echo"hola";
}

And its never executing. In the same file I'm using the custom_views_alter_query and is executing perfectly.

Any ideas? Thank you!

Upvotes: 0

Views: 1306

Answers (3)

Tyler Fahey
Tyler Fahey

Reputation: 101

I came across this when facing a similar issue - I was trying to ksm() inside the pre_execute hook, and it was only firing for one of my views on the page, but not the other (I had 2 Views blocks placed). I realized that an issue with the contextual filter was the issue... Views does a lot of try/catch internally, so you don't always get a fatal "WSOD", but check the watchdog for clues this might be happening - I was getting a "Warning" related to the contextual filter... removing it allowed me to at least see the ksm() output and move forward... hopefully this might help someone.

Upvotes: 0

srutheesh
srutheesh

Reputation: 34

I think it is because of the caching issue, please clear your drupal cache and try again so that the hook will works fine.

Upvotes: 1

Mihaela
Mihaela

Reputation: 109

"Adding output to the view can be accomplished by placing text on $view->attachment_before and $view->attachment_after." This is from Views API. This function will execute just before the db query. Try some debugging, if nothing works.

Upvotes: 0

Related Questions