hi guys,

how can i use php code in the add block page in
admin/build/block

Thanks
Rams

Comments

papile’s picture

That is a bit of a vague question. What do you mean by use PHP, what are you seeking to do? If you want to alter that page and put dynamic elements in there with a custom module you will have to use hook_form_alter.

RamMohanSakhamuri’s picture

Hi papile,

Thx 4 response...here i have a requirement to use Varialbles in the Block. So i added a new block, in that i wrote php code and applied PHP filter in Input Format. But its not applying in the block(it is printing with php tags as normal text in the block).

thx again,
Rams

cog.rusty’s picture

Just create a block ("Add block"), select "Php code" in the "Input format" section (if you have permission for that or if you are user 1), and put your code in the block's body, inside <?php ... ?> tags.

You didn't mention your Drupal version. If it is an older version, test your code on a page first, because if it contains any serious errors and is rendered on all drupal pages, you may be unable to access the block to fix the code.

If you are using Drupal 6, make sure to enable the "PHP filter" module in admin/build/modules

RamMohanSakhamuri’s picture

Hi rusty,

Yeah!! created a new block as u suggested. I selected PHP as Input Format filter. But It is Displaying with PHP Tags in the block a Normal Test. I am using Drupal 6.x. i enabled PHP filter module,but no use.

thanks,
Rams

cog.rusty’s picture

Go to the admin/settings/filters page and then "configure" the "PHP code" input format and make sure that only the "PHP evaluator" filter is selected in it and no other filter.

097633’s picture

thanks