You are here

README.txt in Automatic Nodetitles 7

Same filename and directory in other branches
  1. 8 README.txt
  2. 5 README.txt
  3. 6 README.txt
Description
-----------
This is a small and efficient 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:
 
<?php return "Author: $node->name"; ?>

 
Advanced Use: Combining tokens and PHP
---------------------------------------
 You can combine php evaluation 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:
 
 <?php
   $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".


Automatic node title alter hook
-------------------------------
This module provides a hook to alter automatic node title. Other modules can
implement this hook to alter node title generated by this module. This hook can
be helpful to set node title based on some business logic.

Note: This hook will not be fired for the nodes those already have automatic
node title set by this module. Once a automatic node title is applied to a node
this modules sets a flag "auto_nodetitle_applied" on that node to prevent
reapplying of node title.

Here is an example:

<?php
/**
 * Implements hook_auto_nodetitle_alter().
 */
function hook_auto_nodetitle_alter(&$node) {
  // Alter node title here.
  if (strpos($node->title, 'world') !== false) {
    $node->title = 'Hello world!';
  }
}
?>

File

README.txt
View source
  1. Description
  2. -----------
  3. This is a small and efficient module that allows hiding of the content title
  4. field in the form. To prevent empty content title fields it sets the title
  5. to the content type name or to an configurable string. It is possible to use
  6. various content data for the autogenerated title, e.g. the token [current-user:name]
  7. is going to be replaced with the currently logged in users name. If the token
  8. module is installed, a list of possible replacement patterns will be shown.
  9. Advanced users can also provide some PHP code, that is used for automatically
  10. generating an appropriate title.
  11. Installation
  12. ------------
  13. * (optional) Download and install the token module in order to get token
  14. replacement help.
  15. * Copy the module's directory to your modules directory and activate the module.
  16. * For each content type you want to have an automatic title, configure the
  17. module at 'admin/structure/types'.
  18. Note
  19. -----
  20. Due to the way the module works, it is not possible to make use of some replacement
  21. tokens that are not available before the content node is saved the first time,
  22. e.g.like the node id ([node:nid]).
  23. Advanced Use: PHP Code
  24. ------------------------
  25. You can access $node from your php code. Look at this simple example, which just adds the node's author as title:
  26. name"; ?>
  27. Advanced Use: Combining tokens and PHP
  28. ---------------------------------------
  29. You can combine php evaluation with the token module, because tokens are replaced
  30. first. However be aware to don't use this with any textual values provided by
  31. users as this would open a security hole. If you are in doubt, don't combine
  32. tokens with php evaluation.
  33. Here is an example:
  34. $token = '[field_testnumber]';
  35. if (empty($token)) {
  36. return '[type]';
  37. }
  38. else {
  39. return $token;
  40. }
  41. ?>
  42. So if the text of the number field [field_testnumber] isn't empty it will be used as title.
  43. Otherwise the node type will be used.
  44. Updating nodetitles from existing nodes
  45. ---------------------------------------
  46. If you set the nodetitle to be auto generated for some content type, existing nodes
  47. are not affected. You can update existing nodes by going to 'admin/content',
  48. then filter for your content type, mark some nodes and choose the "Update option"
  49. "Update automatic nodetitles".
  50. Automatic node title alter hook
  51. -------------------------------
  52. This module provides a hook to alter automatic node title. Other modules can
  53. implement this hook to alter node title generated by this module. This hook can
  54. be helpful to set node title based on some business logic.
  55. Note: This hook will not be fired for the nodes those already have automatic
  56. node title set by this module. Once a automatic node title is applied to a node
  57. this modules sets a flag "auto_nodetitle_applied" on that node to prevent
  58. reapplying of node title.
  59. Here is an example:
  60. /**
  61. * Implements hook_auto_nodetitle_alter().
  62. */
  63. function hook_auto_nodetitle_alter(&$node) {
  64. // Alter node title here.
  65. if (strpos($node->title, 'world') !== false) {
  66. $node->title = 'Hello world!';
  67. }
  68. }
  69. ?>