Evanss
Evanss

Reputation: 23593

PHP in block in Drupal not working

I have the following in a block where the text format is PHP code. For some reason the php is just stripped out when I view the page.

<a href="<?php print base_path(); ?>node/add/f2?edit[field_f2][und]=<?php print arg(2); ?>">New</a>

Upvotes: 0

Views: 1529

Answers (3)

IT-Dan
IT-Dan

Reputation: 565

Besides enabling the 'PHP Filter' module and setting the correct permissions, you also need to edit the format type here:

/admin/config/content/formats/php_code

Tick the 'Roles' you want to have access, and tick the 'PHP evaluator' filter option.

Upvotes: 1

Colin M
Colin M

Reputation: 13348

You have a mismatched tag:

<a href="<?php print base_path(); ?>/node/add/f2?edit[field_f2][und]=<?php print arg(2); ?>"New</a>

Should be:

<a href="<?php print base_path(); ?>/node/add/f2?edit[field_f2][und]=<?php print arg(2); ?>">New</a>

Notice the extra > before the "New"

Upvotes: 1

Ankit
Ankit

Reputation: 1510

There is a ; missing after print base_path().
It should be print base_path();

Upvotes: 0

Related Questions