I've created a custom block, checked "PHP code" for input format and placed this in the Block body:

global $user;
print $user->name;

When I view the page I see exactly what I typed above, not the name. I can't find any forum topics discussing this so I must have some config not set right. Any ideas?

Thanks,
Paul

Comments

thorie79’s picture

What version of Drupal, Apache, and PHP are you using? What extra modules installed? Do you get the same problem if you put that as PHP as a node? That code works fine for me.

pbland’s picture

I tried in a new node and I get the same, just the php is displayed.

Here are my versions are:
drupal - 5.3
Apache - 2.0
PHP - 4.4.7
Modules - CCK, Menu, Taxonomy, Search, Webform, Whizzywig, Views

Any help would be greatly appreciated.

---------------------------------------------------------------
My drupal site: Vacation-Places

gpk’s picture

I think you may need to click the <> button at the RH end of the Whizzywig toolbar so you can see the HTML source. For example, Whizzywig has probably encoded <?php as &lt;?php.

gpk
----
www.alexoria.co.uk

pbland’s picture

I clicked the <> to get into HTML Source mode, but when I save it, my php (from an earlier post) turn into:
name; ?>

I think my problem is being caused by Whizzywig. Does anyone else experience this? Is there a workaround?

---------------------------------------------------------------
My drupal site: Vacation-Places

BradM’s picture

I don't use Whizzywig but I use tinyMCE, maybe they're similar.

I'm not sure I understand, but is the problem the fact that the Whizzywig interface appears in the textarea when building a new block? If so, you should be able to disable it by going to its admin and telling it not to appear on /admin/build/block/add ... this should disable it when adding blocks.

gpk’s picture

I don't use Whizzywig either. Another quick workaround might be to disable the module (or deny permission to your own user role) at least while you are setting up your PHP content. One the block/node is saved in the DB and you've finished making changes to it then you should be OK to re-enable Whizzywig.

Ultimately there are better solutions I'm sure (e.g. BradM's if that option is available and you can get it to work) but this might solve the immediate problem for now. (Might be worth looking in Whizzywig's issue queue to see if there is a patch there, or maybe this has been fixed in the latest dev version.)

gpk
----
www.alexoria.co.uk

pbland’s picture

@BradM - thanks for the reply.

@gpk - thanks once again for helping me. Disabling Whizzywig, adding the code and then enabling Whizzywig solved my problem. I'll take a look and see if there's a patch for Whizzywig.

---------------------------------------------------------------
My drupal site: Vacation-Places