Last active
October 21, 2015 17:11
-
-
Save morad7/4198246e2487d7e64850 to your computer and use it in GitHub Desktop.
Auto increment nodes titles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for auto_nodetitle module | |
<?php | |
$count = db_select('node')->fields('node')->condition('type', $node->type)->execute()->rowCount(); | |
$id = $count+1; | |
$title = 'stg'.$id; | |
$nodes = db_select('node', 'a')->fields('a', array('title'))->condition('type',$node->type)->execute(); | |
foreach ($nodes as $nod) { | |
if ($title == $nod->title) { | |
$id = $id + 1; | |
$title = 'stg'.$id; | |
} | |
} | |
print $title; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment