How have multiple instances of a Custom Block? So I have a custom block that has been created within the module. I have used the drupal API to generate the brand new fields - which works perfectly.

However, I am having an issue regarding multiple instances of the custom block. As I want the blocks to be sandboxed as the custom fields are only related to the block used within the one region.

Now using Multi Block, I can create another instance of that block but the field is exactly the same. What would be the best approach for having one block but whenever its used, its custom fields per block.

case 'live_chat_block' :
    variable_set('text_variable', $edit['text_body']);
break;


Now the idea I had was to add in the "panel page" as variable ID but there might be a better way. Any suggestions would be useful.



Just to expand on what i would like to achieve:

We currently have panel pages implemented and we have built a custom block with custom fields inside that custom block. The requirement is that every block that we drag into one of the panel pages, we would like for them to have unique fields. 

Panel Page: 1
Block ID: 123
Custom Field Title: Superman

Panel Page 2:
Block ID: 123
Custom Field Title: Batman

Now as you see, the only thing that changes is the panel pages, the block stay the same and the custom fields need to be unique to that panel page and not the block.

Currently, when changing one block, it impacts on all the other blocks as well.

function livechat_block_configure($delta=''){
  $form = array();

  switch($delta) {
     case 'live_chat_block' :
        // checkbox example:
      $form['text_body'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Enter in Title here'),
        '#default_value' =&gt; variable_get('text_variable', ''),
      );


        break;
  }
  return $form;

}
Add the following function in your template.php   

function &lt;themeName&gt;_render_block($module, $delta, array $options = array()){
  $default_options = array(
    'title' =&gt; '&lt;none&gt;',
    'region' =&gt; -1,
  );

  $options = array_merge($default_options, $options);

  $block = db_query('SELECT * FROM {block} WHERE module = :module AND delta = :delta', array(':module' =&gt; $module, ':delta' =&gt; $delta))-&gt;fetchObject();
  if($block) {
    $block = block_load($module, $delta);
    $block-&gt;title = $options['title'];
    $block-&gt;region = $options['region'];
    $blocks = array($block);
    $rblocks = _block_render_blocks($blocks);
    $render_array = _block_get_renderable_array($rblocks);
    return drupal_render($render_array);
  }
  return "";
}


then when you want to render the block just write the following line

print render &lt;themeName&gt;_render_block($module_name, &lt;id of block&gt;, array of options like title etc)


You can find module name and block id by going to block configuration page so for the path
admin/structure/block/manage/views/locations-block_1/configure
module name is "views" and id is "location-block_1"

So the render function will be 

print render &lt;themeName&gt;_render_block("views", "location-block_1", array("title" =&gt; t("My block title")));