• RESUME
  • LOGIN

balanced scale media

  • blog
  • projects
  • services
  • contact
Home › Blogs › boz's blog

Automated Node Titles Without Auto Node Title

boz — Thu, 10/06/2011 - 14:04

I am a features user and if you are too then you will share my frustration when you find aspects of other modules that are not exportable, i.e. not capable of being packaged in your feature. Such is the case with the Auto Node Title module. However, this is to be expected right? Ctools module provides the api for making things exportable and we should know not every developer will go ahead and implement this in their module. So back to our discovery of the non-exportable. When we get to this point there are several options. One being "don't use the module" and another being "write an exportable". Now auto node title is a common enough module that it might benefit from writing an exportable, but in my opinion that is code bloat where it is not needed. You can accomplish the same thing as auto node title with two Drupal hooks which you can include in the .module file of your feature. Problem solved.

function quick_note_form_alter(&$form, &$form_state, $form_id){      
  if($form_id == 'note_node_form') {        
    // Hide title input box     
    $form['title']['#type'] = 'hidden';       
    // Set a generic value to pass validation     
    $form['title']['#value'] = 'Quick Note ';   
  } 
}  

function quick_note_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {   
  if($node->type == "note") {     
    switch($op) {       
      case "presave":         
        // Add timestamp to node title for uniqueness         
        $node->title .= date();        
      break;     
      }   
  } 
}

  • Drupal
  • boz's blog
  • Add new comment

Recent Posts

  • Generate Word Documents With PHP
  • Delete CCK Inactive Fields
  • Delete Nodes From A Certain Date in Drupal
  • Automated Node Titles Without Auto Node Title
  • Drupal Camp Iowa Ajax Example
  • Get Paid To Learn Drupal!
  • Presenting "JavaScript Guidelines : When and When Not to Script"
  • Drupal Form Alter on a Node Reference Widget
  • The Paradox Of Drupal
  • Programmatically Creating Users in Drupal with Profile Fields
more

Topics

  • Android
  • Apace
  • Aptana
  • Bazaar
  • Browser
  • Code
  • Drupal
  • Eclipse
  • Flex
  • HTML 5

Archive

  • February 2008 (1)
  • May 2008 (1)
  • July 2008 (3)
  • December 2008 (2)
  • January 2009 (2)
  • March 2009 (3)
  • April 2009 (5)
  • May 2009 (1)
  • July 2009 (1)
  • August 2009 (3)
more

Links

 

  • blog
  • projects
  • services
  • contact

© 2012 Balanced Scale Media, LLC. All Rights Reserved.