is it standard or good way to put code in block with php fiter format and use another drupal benefit (handling users,contents,roles,another modules)?

for example i need to use jquery ui dialog. i can use this module. another way is to paste jquery ui dialog script in php code block.


i need a special query from database for admin. i have create a page and use content access module and paste my code (including html,jquery.php) in php code block.

or inserting user in drupal database with query in block

2 Answers 2


It is in most cases a bad idea, unless there is no other way. See What are the downsides of using PHP Filter code in blocks, nodes, views-args, etc?, which is pretty much the same question.

Instead of creating a block/page/... with PHP code, I suggest you create a module that exposes a block or uses hook_menu() to expose a page.


I would say it depends. If you want to have the code editable via the UI this is ok. In that case the code may be seen as part of the content and I think it fits. Another case would be if you don't want to write/update an own module or theme.

In every other case I would always try to bring the code into the filesystem instead of the database. There are multiple reasons for that:

  • reuseability of code (keep it DRY)
  • use of version control (like git or svn)
  • better maintainability of codebase

Apart from that I think many things simply can't be done without writing own modules (and implement drupal hooks and stuff like that) and themes but the other way around I don't see such limitations. Correct me if i'm wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.