How to display multiple blocks using a custom calendar module? I have created a calendar module in Drupal 7. In addition to the default calendar on the website, my client can create a new calendar for events specific to a particular page.

Say that they want to add "Youth" and "College and Career" calendars; the db table looks like this:

table: churchcal_calendars

------id------|------name-----|------set_default------

------1-------------Main---------------1--------

------2-------------Youth--------------0---------

------3-------College and Career---------0-----------

In my churchcal.module file, I have set hook_block_info and hook_block_view:

function churchcal_block_info() {
    $blocks = array();
    $blocks['monthly_calendar'] = array(
        'info' =&gt; t('Display the monthly calendar.'),
        'cache' =&gt; DRUPAL_NO_CACHE,
    );

    //get calendars
    include('db.php');
    $result = mysql_query("SELECT * FROM churchcal_calendars WHERE set_default != '1'");
        while($row = mysql_fetch_array($result)) {      
            $cal_name = $row['name'];
            $sys_cal_name = strtolower(str_replace(' ', '_', $cal_name));
            $blocks['churchcal_' . $sys_cal_name] = array(
                'info' =&gt; t('Display calendar for ' . $cal_name . '.'),
                'cache' =&gt; DRUPAL_NO_CACHE,
            );
        }

    return $blocks;
}

function churchcal_block_view($block_name = '') {
    if ($block_name == 'monthly_calendar') {
        $content = monthlyCalendar();
        $block = array (
            'subject' =&gt; t(''),
            'content' =&gt; $content,
        );
    }

        //get calendars
        include('db.php');
        $result = mysql_query("SELECT * FROM churchcal_calendars WHERE set_default != '1'");
            while($row = mysql_fetch_array($result)) {
                $cal_name = $row['name'];
                $sys_cal_name = strtolower(str_replace(' ', '_', $cal_name));
                $cal_id = $row['id'];

                if($block_name == 'churchcal_' . $sys_cal_name) {
                    $content .= churchCal($cal_id);
                    $block = array(
                        'subject' =&gt; t('Upcoming Events'),
                        'content' =&gt; $content,
                    );
            }

        return $block;
    }
}


The "monthly_calendar" is the main calendar, and there is no problem with that block.

Beneath the monthly calendar is the code for the additional calendars. I can see each calendar in admin/structure/block page (for the example "Display calendar for Youth", "Display calendar for College and Career"). That part works great. However, I can only see one calendar, and that is whichever is first in the db with default != 1. In this example, the Youth calendar would display, but not the College and Career. So, it tells me that hook_block_info is correct and there is a problem with hook_block_view.

How can I display a calendar for each calendar in the db?
It looks like you should review that "return $block;" that you inserted in the while() statement.

PS: not sure why you didn't (couldn't) post your own answer, which is why I do so now anyway ...