I am using the aqua marina theme and referencing "sidebarfirst" blocks to have them themed accordingly in cck content. The only thing is the title does not show up for the blocks, just the block content.

Thanks so much for your module, it is a life saver!

CommentFileSizeAuthor
#1 blocksref.png57.18 KBg76

Comments

g76’s picture

StatusFileSize
new57.18 KB

forgot to attach screenshot. sorry.

danielb’s picture

Hmm seems I need to some more field formatter options!

If you know how you could theme the default formatter correctly

here is the original theme function for reference


/**
 * Theme function for 'default' blockreference field formatter.
 */
function theme_blockreference_formatter_default($element) {
  $field_name = $element['#field_name'];
  $field = content_fields($field_name);
  $output = '';
  if (!empty($element['#item']['bid']) && is_numeric($element['#item']['bid'])) {
    $block = db_fetch_object(db_query(db_rewrite_sql("SELECT * FROM {blocks} WHERE bid = ".$element['#item']['bid'], 'blocks', 'bid')));
    $block->enabled = TRUE;
    $block->status = TRUE;
    $block->page_match = TRUE;
    $block_view = module_invoke($block->module, 'block', 'view', $block->delta);
    $block->content = $block_view['content'];
    $output = theme('block', $block);
  }
  return $output;
}
g76’s picture

Thanks for the reply. I wish I knew more about this, I would be more than happy to help, but I am not a coder. I feel at a loss. Maybe if this issue is left open, others can pitch in who have a better understanding of things. Again, I am sorry I can't help, I wish I could.

danielb’s picture

I will jump on and work out the solution before the end of the week I suspect it is this (off the top of my head)

/**
* Theme function for 'default' blockreference field formatter.
*/
function phptemplate_blockreference_formatter_default($element) {
  $field_name = $element['#field_name'];
  $field = content_fields($field_name);
  $output = '';
  if (!empty($element['#item']['bid']) && is_numeric($element['#item']['bid'])) {
    $block = db_fetch_object(db_query(db_rewrite_sql("SELECT * FROM {blocks} WHERE bid = ".$element['#item']['bid'], 'blocks', 'bid')));
    $block->enabled = TRUE;
    $block->status = TRUE;
    $block->page_match = TRUE;
    $block_view = module_invoke($block->module, 'block', 'view', $block->delta);
    $block->content = '<h3 class="title">'.$block_view['info'].'</h3>'.$block_view['content'];
    $output = theme('block', $block);
  }
  return $output;
}
manuel garcia’s picture

That isn't working danielb... apparently the array $block_view only has 'content' in it... , at least in my print_r().

manuel garcia’s picture

Ok, I have gone again in the code and I think i understand a bit better what's going on...

Forgive me but I'm not in the know on how to make patches,.. this is what fixes the issue:

Problem is in this function inside blockreference.module

/**
 * Theme function for 'default' blockreference field formatter.
 */
function theme_blockreference_formatter_default($element) {
  $field_name = $element['#field_name'];
  $field = content_fields($field_name);
  $output = '';
  if (!empty($element['#item']['bid']) && is_numeric($element['#item']['bid'])) {
    $block = db_fetch_object(db_query(db_rewrite_sql("SELECT * FROM {blocks} WHERE bid = ".$element['#item']['bid'], 'blocks', 'bid')));
    $block->enabled = TRUE;
    $block->status = TRUE;
    $block->page_match = TRUE;
    $block_view = module_invoke($block->module, 'block', 'view', $block->delta);
    $block->content = $block_view['subject'] . $block_view['content'];
    $output = theme('block', $block);
  }
  return $output;
}

Change the line: $block->content = $block_view['subject'] . $block_view['content'];
To this: $block->content = $block_view['content'];
And add this line below that one: $block->subject = $block_view['subject'];

For the time being, people you can just override this function in your template.php until it is fixed in the next release.

You can do so using this:


/**
 * Theme function for 'default' blockreference field formatter.
 */
function YOURTHEMENAME_blockreference_formatter_default($element) {
  $field_name = $element['#field_name'];
  $field = content_fields($field_name);
  $output = '';
  if (!empty($element['#item']['bid']) && is_numeric($element['#item']['bid'])) {
    $block = db_fetch_object(db_query(db_rewrite_sql("SELECT * FROM {blocks} WHERE bid = ".$element['#item']['bid'], 'blocks', 'bid')));
    $block->enabled = TRUE;
    $block->status = TRUE;
    $block->page_match = TRUE;
    $block_view = module_invoke($block->module, 'block', 'view', $block->delta);
    $block->content =  $block_view['content'];
    $block->subject = $block_view['subject'];
    $output = theme('block', $block);
  }
  
  return $output;
}
danielb’s picture

That's it, is it? Thanks for working that - out we've had some massive storms here with power outages and all sorts of nonsense so I haven't had a chance.

manuel garcia’s picture

As far as we can tell, that does fix the issue yep, although it'd be nice if someone else actually tested it and gave their feedback here just in case.

danielb’s picture

Status: Active » Needs review
danielb’s picture

Status: Needs review » Fixed

I have commited the code in version 6.x-1.10

manuel garcia’s picture

great, thanks danielb

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.