I have a insert_data module that used to insert data to category table, and I also have a module named mysite that has a function named “function mysite_preprocess_panels_pane(&$variables) “ is used to render data to panel.tbl.php.

My question is how can I call function “mysite_preprocess_panels_pane(&$variables)” from mysite module.

My purpose is after inserting data to table I want to show update data in home page(panel.tbl.php). I am new to drupal I need help or suggestion. Thanks

Insert_data module

function insert_data($fn,$data) {
    $status =1;
    $cid = db_insert('category') // Table name no longer needs {}
   'name' => $data['name'],

   module_load_include('module', 'mysite', 'mysite');
   function mysite_preprocess_panels_pane();
   $reply= (array('status' => $status,'category' => $cid) );
   return $reply;

Calling mysite_preprocess_panels_pane() without parameter will be fine?

Mysite module

function mysite_preprocess_panels_pane(&$variables) {
    $query = db_select('category', 'n');
    $items = $query->execute()->fetchAll();

    $variables['ar'] = $items;


<div class="panel-panel panel-col-first">a 
        if (isset($variables['ar'])) {
             foreach (array_keys($variables['ar']) as $name) {
             print render($ar[$name]);


1 Answer 1


Instead of implementing template_preprocess_panels_pane() and inserting your content there is something called ctools content types.

A ctools content type shows up in the panels interface as panes that can be added to a region.

In your case I would create a ctools content type in your module mysite.

Basically it's a block that contains rendered data that can be placed in a region of your choice.

It will be more easy to understand for other developers how the data is inserted on the front page also since it will be visible in the Panels interface.

 * Implements of hook_ctools_plugin_directory().
function MYMODULE_ctools_plugin_directory($module, $plugin){
  if ($module == 'ctools' || $module == 'panels'){
    return 'plugins/' . $plugin;

Then create a folder in your module called plugins and in that folder create a folder called plugins. Place a file called MYPLUGIN.inc The file should then be placed in mymodule/plugins/content_types/MYPLUGIN.inc

Place this content in your MYPLUGIN.inc


$plugin = array(
  'single' => TRUE,
  'title' => t('MYPLUGIN'),
  'render callback' => 'MYPLUGIN_content_type_render',
  'description' => t('Renders something.'),
  'category' => t('Custom'),
  'edit form' => 'MYPLUGIN_content_type_edit_form',

 * Render the custom content type.
function MYPLUGIN_content_type_render($subtype, $conf, $panel_args, $context) {
  $block = new stdClass();
  $block->content = 'MYDATA';
  return $block;

 * Edit callback.
function MYPLUGIN_content_type_edit_form($form, &$form_state) {
  $conf = $form_state['conf'];
  return $form;

 * Implements hook_form_submit().
function MYPLUGIN_content_type_edit_form_submit($form, &$form_state) {
  foreach (element_children($form) as $key) {
    if (!empty($form_state['values'][$key])) {
      $form_state['conf'][$key] = $form_state['values'][$key];

Now replace $block->content with the data you want to be rendered.

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .