We all know that putting PHP code in the database is icky, scary, security hole, performance problem, featurization problem, and so forth. OK, cool.

The computed_field module, offers the ability to fill in a magic function name that will get used in place of whatever is filled in using the UI. The format is fixed, and is based on the field name. It's also listed in the UI for easy copy and paste. If that function is found, then the UI for setting the computing logic is hidden entirely in favor of that callback function.

The advantages of this approach are
1) You can use a real code editor.
2) Bugs in the code don't instantly break your site without the ability to fix it.
3) Code in a custom module is version controllable, doesn't need features, etc.
4) People without code-editing access cannot go changing logic on you from the UI.
5) It's easier to document.

All of those benefits would apply to auto_nodetitle, too. I'd much rather use that approach than editing PHP directly in the UI (for those title patterns too complex for tokens, like if there's a conditional). So, consider this a feature request for such an option.

Comments

texas-bronius’s picture

Status: Active » Closed (works as designed)

I'm taking a stab at this 1 year old issue to suggest that without any code changes, you can (and, I agree, should!) use external functions to provide node titles. You can do it with the php snippet (including php tags):
return mymodule_custom_function($node);
and check the Evaluate PHP checkbox on the content type's auto nodetitle config.

Note that passing in $node is not necessary unless you need it in your function. Key here is to tie UI with your external function using return and a call to an externally provided php function.