home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (block.inc)

This example Drupal source code file (block.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, block, build, content, empty, function, if, isset, pane, php, return, the, theme_wrappers, variable

The block.inc Drupal example source code

<?php

/**
 * @file
 * Definition of the 'block' panel style.
 */

// Plugin definition
$plugin = array(
  'title' => t('System block'),
  'description' => t('Display the pane as a system block; this is more restrictive than the default.'),
  'render pane' => 'panels_block_style_render_pane',
  'weight' => -10,
);

/**
 * Render callback.
 *
 * @ingroup themeable
 */
function theme_panels_block_style_render_pane($vars) {
  $content = $vars['content'];
  $pane = $vars['pane'];

  if (empty($content->content)) {
    return;
  }

  $block = clone($content);

  if (!empty($block->title)) {
    $block->subject = $block->title;
  }

  $block->region = $pane->panel;
  if (!isset($block->module)) {
    $block->module = $block->type;
  }
  if (!isset($block->delta)) {
    $block->delta = $block->subtype;
  }

  $build = $block->content;
  if (is_string($build)) {
    $build = array('#markup' => $build);
  }

  $build['#block'] = $block;
  $build['#theme_wrappers'][] = 'block';

  // If using per pane classes, $block->css_class will need to be added in your
  // preprocess or template, along with any other Panels specific field you
  // might want to utilize.
  return drupal_render($build);
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal block.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.