How to hide the label "Title" for products?
Is there a way to hide the label "Title" when displaying products? It seems to be impossible to hide the label of a title field.
Sure it's possible to hide the title field entirely and create another textfield where I can hide the label and use this field to display the title of my products. But that's an ugly solution. Is there a better way?
Thanks
Thomas
Comments
This is a issue more with
This is a issue more with Drupal and how it displays the title of a node. The exclude node title module should do the trick. http://drupal.org/project/exclude_node_title
Exclude Node Title Didn't help
I installed this module, but I could not find where I could remove the Title Label for a Product in a Product Display node. In fact, Commerce Product Types don't show up in the configuration for this module at all, only Content Type Nodes.
Maybe I'm missing something, it wouldn't be the first time!
Thanks for any additional help in advance!
Steve
I encountered this problem
I encountered this problem too. I found that if I installed the Display Suite module and changed the layout of the Product Display Node it actually gives you another title (Disabled) which is just called Title. If you then disable the normal Product:Title and replace it with the Title then you get a nice title without the label.
This is one of those stupid little things that I hate about Drupal Commerce.
Display Suite isn't Helping Either
I already had Display Suite installed and this was what I tried first. But even with this I don't see any option to hide the Title Label for a Product in a Product Display node or in the Product Type Manage Display.
As I said above, maybe I'm missing something here too!
Thanks for any additional help in advance!
Steve
Thanks
This worked perfect. Thanks a million
This worked well for me:
This worked well for me:
In CSS:
.commerce-product-title-label {display:none;}
This is always the last resort isn't it?
Of course hiding the rendered code with CSS is always an option, but there should be a better way to do this. Are all the examples on KickStarter using CSS to hide the Title Label for the each Product Title?
Things like this drive me crazy!
Steve
You can use this snippet in a
You can use this snippet in a custom module to overwrite the output of the title.
function {my-module-name}_entity_view_alter(&$build, $type) {
if ($type == 'commerce_product') {
$build['title']['#markup'] = '<div class="commerce-product-title">' . $build['#entity']->title . '</div>';
}
}
On Node display
function hook_entity_view_alter(&$build, $type) {
if ($type == 'node') {
if (isset($build['product:title'])) {
$search = array('', 'Title: ');
$build['product:title']['#markup'] = str_replace($search, '', $build['product:title']['#markup']);
}
}
}
On Node display
If you view the node, try this alternative.
function hook_entity_view_alter(&$build, $type) {
if ($type == 'node') {
if (isset($build['product:title'])) {
$search = array('<div class="commerce-product-title-label">', 'Title: </div>');
$build['product:title']['#markup'] = str_replace($search, '', $build['product:title']['#markup']);
}
}
}
Using a Template file override
Add a template file called commerce-product-title.tpl.php in your theme.
In this example I have commented out the code that prints the label.
<?php
/**
* @file
* Default theme implementation to present the title on a product page.
*
* Available variables:
* - $title: The title to render.
* - $label: If present, the string to use as the title label.
*
* Helper variables:
* - $product: The fully loaded product object the title belongs to.
*/
?>
<?php if ($title): ?>
<div class="commerce-product-title">
<?php /* if ($label): ?>
<div class="commerce-product-title-label">
<?php print $label; ?>
</div>
<?php endif;*/ ?>
<?php print $title; ?>
</div>
<?php endif; ?>