I have a content type whose human readable name is Post your blog. How can I get the content type machine name by the human readable name?
Is there a function in Drupal 7, or do I have to query the node_type table to get what I want?
I have a content type whose human readable name is Post your blog. How can I get the content type machine name by the human readable name?
Is there a function in Drupal 7, or do I have to query the node_type table to get what I want?
You can easily build a query to achieve this. However, as Molot mentioned, you have to handle human readable names that aren't unique.
$machine_name = db_select('node_type', 'n')
->fields('n', array('type'))
->condition('name', 'Basic page')
->execute()->fetchField();
$machine_name = db_query('node_type', 'n') $machine_name->fields('n', array('type') $machine_name->condition('name', 'Post your blog') $machine_name->execute()->fetchField();
Commented
Jun 5, 2013 at 16:27
$node
object from within search-result--node.tpl.php
: $variables['result']['node']
- drupal.org/comment/reply/535578/6186406 and 2) with the $node
object, get the type in machine name form and its human name equivalent: node_type_get_name($node)
- api.drupal.org/api/drupal/modules%21node%21node.module/function/…
Commented
Sep 4, 2013 at 16:18
Look at node_type_get_types for D7 and simply foreach
looking for $object->name
as Post your blog
.
node_type_get_types
function , it didn't work for my case
Commented
Jun 5, 2013 at 16:31