When making a PHP block (eg an alternative login block), the resulting block is included/executed at the wrong place. It is included even before the HTML declaration.

The same block displayed in the correct location in 4.3, and if I set the block to HTML instead of PHP, it also renders correctly (without actually doing what I wanted it to do ofcourse ;-)).

Comments

Steven’s picture

...you were supposed to return the contents of a PHP block. Not sure if that was changed or not.

ahoeben’s picture

Don't know how I missed that. I guess I was thrown off because in 4.3 I could just echo into a block.

Pascal’s picture

This works for me.

Drupal 4.4.0 takes the blocktitle from the form.
A block for example:

$block  = "Hello user, your ip-adress is: <b>" .$_SERVER['REMOTE_ADDR']. "</b>. ";
$block .= "Have a nice day.";
return $block;

Don't forgett to remove the PHP-Tags. ;-)

herbivorous’s picture

I had a working 4.3 php block that returned a block thusly --


global $theme;
$theme->block($subject, $desc.theme_item_list($output).$more);

(Junk where $subject, $output, & $more were created left out, though perhaps that is where the problem lies and not with how it is actually output.)

But now the block doesn't function under 4.4

Is the problem in how I ask for it to be displayed? Should I be returning something? What?

Thanks.

herbivorous’s picture

The most useful answer I could get would probably be someone telling me how to set the title/subject of a block from within a PHP block, though I gather this isn't possible.

The second most useful answer might be telling me where to hack this to make it possible, and how to hack it such that it doesn't end up messing up the pre-installed blocks. (Though maybe I can stumble through this last bit.)

I do see that it is possible to set the block title within a module, and I've played with this a little. However, I'm not well-versed enough to figure out the best way to handle my situation, which is this: my PHP block actually generates (well, generated, back in the good old days) 1-4 separate blocks based on how many categories of appropriate related content their were. A simple loop, spitting out a block then looping back if there were more blocks that needed to be spit out.

It isn't clear to me that the php block system in 4.4 -- even if I can set the title -- will handle this. And I'm not sure either how to get a block module to do this looping while keeping separate the various aspects of the block.

I'm plugging away at it, but would appreciate any pointers that people could provide.

Thankee.