Score:0

drupal 7: no hooks run on page load

cn flag

I have site on drupal 7. I'm creating a module to add a poll on-page instead of a template string. As I understand, I should do it in some hook-like hook_page_load, hook_init, hook_boot, etc I created some hooks in my autopolling.module:

<?php
error_log("in autopolling\n",3,'D:\\TEMP\\temp\\php.log');

function autopolling_block_info(){
    error_log("autopolling_block_info\n",3,'D:\\TEMP\\temp\\php.log');
    $blocks['myblock'] = array(
        'info' => t("My custom block"),
    );
    return $blocks;
}

function autopolling_node_insert($node) {
    error_log("autopolling_node_insert\n",3,'D:\\TEMP\\temp\\php.log');
}
function autopolling_insert($node) {
    error_log("autopolling_insert\n",3,'D:\\TEMP\\temp\\php.log');
}

function autopolling_page_alter(&$page) {
    error_log('autopolling_page_alter',3,'D:\\TEMP\\temp\\php.log');
}
function autopolling_node_load($nodes, $types)
{
    error_log("autopolling_node_load\n", 3, 'D:\\TEMP\\temp\\php.log');
}
function autopolling_node_view($entity, $type, $view_mode, $langcode)
{
    error_log('autopolling_node_view', 3, 'D:\\TEMP\\temp\\php.log');
}
function autopolling_entity_view($entity, $type, $view_mode, $langcode) {
    error_log('autopolling_entity_view',3,'D:\\TEMP\\temp\\php.log');
}
function autopolling_page_build(&$page) {
    error_log('autopolling_page_build',3,'D:\\TEMP\\temp\\php.log');
}
function autopolling_init() {
    error_log('autopolling_init',3,'D:\\TEMP\\temp\\php.log');
}
function autopolling_boot() {
    error_log("autopolling_boot\n",3,'D:\\TEMP\\temp\\php.log');
}

but I've got only "in autopolling" string in my log file (and "autopolling_block_info" if I open admin/structure/block & "autopolling_node_insert" when I add a page).

So, hook_node_load should work, but I've got no record about it. And no records about any other "loading" hook.

I have no errors in drupal journal.

What I'm doing wrong?

cn flag
Sounds like you need to clear the caches
Kevin avatar
in flag
In all these instances, the page will be cached after the first rendering. You'd want to load a poll via AJAX or something from your block output.
cn flag
@Clive I cleared the caches from /admin/config/development/performance some times, but that time it helped, thank you
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.