I have site with several rental properties where each rental property (node) has an Availability Calendar enabled and working perfectly.

I'd like to have a 'summary' page that shows the calendars for all the properties on one page. In a similar vein to the demonstration page.

As a fairly new Drupal user I couldn't see an option to achieve this. I'm guessing that maybe I could create a series of blocks and place them on a node, but I don't know how to get the block to render the AC for a specific node.

Any help appreciated.

Thanks.

Comments

geodaniel’s picture

The way this is achieved on the demo page is through the use of a node with the PHP filter enabled. For each node you want to include the calendar for, you can then insert the following HTML:

  print theme('availability_calendars_node', node_load(array('nid' => 12)), date('Y'), date('m'), variable_get('availability_display_monthcount', 12));

(where 'nid' => 12 is the node ID of the node you wish to show the calendar for)

ianhaycox’s picture

Status: Active » Closed (fixed)

Perfect.

Thanks very much.

JT33’s picture

Version: 6.x-1.1 » 7.x-2.0

Hi

I have been trying to adapt the solution above to D7, but no success so far. Did someone had a go at it?
Many thanks

JT

fietserwin’s picture

D7 theme functions work with 1 variables array: all parameters to the theme are passed in via 1 array. The theme definition for availability_calendars_node expects the following parameters:

file availability_calendars.module:

function availability_calendars_theme() {
  $today = getdate();
  return array(
    'availability_calendars_node' => array(
      'variables' => array(
        'node' => NULL,
        'year' => $today['year'],
        'month' => $today['mon'],
        'monthstodisplay' => 12,
        'showeditlink' => FALSE,
        'settings' => NULL,
      ),
      ...
}

Calling a theme function is done indirectly by using render arrays like in
file availability_calendars.page.inc function availability_calendars_page_node_view:

    $node->content['availability_calendars'] = array(
      '#theme' => 'availability_calendars_node',
      '#node' => $calendar_node,
    	'#year' => $year,
      '#month' => $month,
      '#monthstodisplay' => $settings->monthcount,
      '#showeditlink' => TRUE,
      '#settings' => $settings,
      '#weight' => 10,
    );

Or by calling the theme function directly:

  $output =  theme('availability_calendars_node', array('node' => $node, 'year' => $year, 'month' => $month, ... ));

The settings are passed in as a parameter to allow the calling code to overrule the stored settings in situations where needed. Normally you get them via a call to function availability_calendars_get_settings($scope, $nid).

Don't forget to include the files where these functions live in, they might not be loaded when your php code is executed:

theme functions:

  module_load_include('inc', 'availability_calendars', 'availability_calendars.page');

or the get settings function:

  module_load_include('inc', 'availability_calendars', 'availability_calendars');

(the latter will automatically be included on including the former).

Last note: be aware of the security risks of the PHP filter. You better not use this filter and use hooks to get the output you want, e.g. hook_preprocess_page and using render arrays to add content to your page.

JT33’s picture

Thank you for the prompt and detailed answer Fietserwin. It works fine now.
I also take your point on safety. Will work with a hook on the live version. Just trying a few things in local for the time being.

JT