check if title is set
waby - March 16, 2008 - 02:39
| Project: | Automatic Nodetitles |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
im using the setting "Automatically generate the title and hide the title field"
id like to check if the title has already been set before using php to make the title because when editing the node the title will change even if its been set already.
the php is basicly a auto incr counter which becomes the title of the node.
how can i do this?

#1
I've had a similar problem.
I wanted to use the node creation timestamp to make the title like a product ID eg: 0000-3333-080403 where the last part is the creation date of the node. The problem was that when you first create a node, the creation timestamp is unavailable (the node isn't created yet!) so I decided to use the [nid] token (Token module is needed) to check against.
$nid = '[nid]';if( $nid == '' ){
//if it's a new node (with no nid available), the timestamp is given with the time() function
print format_date( time() , $type = 'custom' , $format='ymd' );
}
else{ //In any other case, the "node created time" is used
$node = node_load( $nid );
print format_date( $node->created , $type = 'custom' , $format='ymd' );
}
You can probably use the [title] token to check against. This doesn't feel like an elegant or optimized solution, but since it is only used on the admin side, I felt like it was sufficient.
I'm from a design background (but I'm not affraid of coding...) so any advice from someone who knows how to access the form data (title and so on) in a more efficient way would be apreciated.