I've got a component that requires me to get the content type of the node the component appears on. I saw there exists a function to get that for me:
node_type_get_name($node)
However, when I use this function within the components pre-process hook, eg:
my_component_preprocess_my_component_theme(&$variables, $node) {
dpm(node_type_get_name($node));
}
I get nothing.
If I dpm($node);
I get the title of the component, not the node.
Would anyone know how I can retrieve the node's content-type?
You can load current node like this:
<?php
$node = menu_get_object();
if ( !empty($node) ) {
print "Have node";
}
?>
So, you'll have full node loaded and can check it's type ($node->type
) and anything else you need.
And if you don't have the node it means, of course, current page is not a node (maybe a view or some custom page...).