function views_megarow_generic_render in Views Megarow 7
Use a generic menu callback to display non megarow tailored pages.
1 string reference to 'views_megarow_generic_render'
- views_megarow_menu in ./
views_megarow.module - Implement hook_menu().
File
- ./
views_megarow.module, line 110
Code
function views_megarow_generic_render($entity_id) {
// Get the arguments passed to the render callback, it's basicaly
// a split path.
$args = func_get_args();
// Remove the entity_id argument.
array_shift($args);
// Clean the values and implode them to generate a clean path.
$path = implode('/', array_filter($args, 'strlen'));
// Get the output of the called page.
$output = menu_execute_active_handler($path, FALSE);
// Allow errors to bubble up. The error is always one of: MENU_SITE_OFFLINE,
// MENU_ACCESS_DENIED, MENU_NOT_FOUND
if (is_int($output)) {
return $output;
}
// The output is valid, display it through AJAX and voilà!
// Render our output if we get a renderable array.
if (is_array($output)) {
// Let's double check if the output isn't already a ajax command.
if (isset($output['#type']) && $output['#type'] == 'ajax') {
return $output;
}
$arguments = array(
'display' => 'error',
);
$messages = theme('status_messages', $arguments);
// Pass the result of this to the modal to display it.
$content = array(
array(
'#markup' => $messages,
),
$output,
);
$output = drupal_render($content);
}
// @TODO Add command to slide to top if errors.
$commands = array();
$commands[] = views_megarow_command_display(variable_get('views_megarow_title', t('Megarow content')), $output, $entity_id);
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}