Automatic Nodetitle Module
------------------------
by Wolfgang Ziegler, nuppla@zites.net
Description
-----------
This is a small and efficent module that allows hiding of the content title field in the form.
To prevent empty content title fields it sets the title to the content type name or to an
configurable string. It is possible to use various content data for the autogenerated title,
e.g. the token [current-user:name] is going to be replaced with the currently logged in
users name. If the token module is installed, a list of possible replacement patterns
will be shown.
Advanced users can also provide some PHP code, that is used for automatically generating an
appropriate title.
Installation
------------
* (optional) Download and install the token module in order to get token
replacement help.
* Copy the module's directory to your modules directory and activate the module.
* For each content type you want to have an automatic title, configure the
module at 'admin/structure/types'.
Note
-----
Due to the way the module works, it is not possible to make use of some replacement
tokens that are not available before the content node is saved the first time, e.g.
like the node id ([node:nid]).
Advanced Use: PHP Code
------------------------
You can access $node from your php code. Look at this simple example, which just adds the node's
author as title:
name"; ?>
Advanced Use: Combining tokens and PHP
---------------------------------------
You can combine php evalution with the token module, because tokens are replaced first.
However be aware to don't use this with any textual values provided by users as this would
open a security hole. If you are in doubt, don't combine tokens with php evaluation.
Here is an example:
$token = '[field_testnumber]';
if (empty($token)) {
return '[type]';
}
else {
return $token;
}
?>
So if the text of the number field [field_testnumber] isn't empty it will be used as title.
Otherwise the node type will be used.
Updating nodetitles from existing nodes
---------------------------------------
If you set the nodetitle to be auto generated for some content type, existing nodes
are not affected. You can update existing nodes by going to 'admin/content',
then filter for your content type, mark some nodes and choose the "Update option"
"Update automatic nodetitles".