function _uc_attribute_get_name in Ubercart 7.3
Same name and namespace in other branches
- 8.4 uc_attribute/uc_attribute.module \_uc_attribute_get_name()
- 6.2 uc_attribute/uc_attribute.module \_uc_attribute_get_name()
Returns the attribute name to display.
An attribute with a label set returns that label except when set to '<none>' . In this case, a NULL is returned. The $title argument forces the function to return the name property instead of label when label is set to '<none>'.
The NULL return value is typically used by forms so they know to hide the #title property of the element.
Parameters
object $attribute: Attribute object.
bool $title: TRUE indicates the function is to return the attribute name when its label is set to '<none>'.
Return value
string|null When the attribute label is set and not '<none>', it is returned. Otherwise, the attribute name is returned when $title is TRUE and NULL is returned when $title is FALSE.
3 calls to _uc_attribute_get_name()
- uc_attribute_node_update_index in uc_attribute/
uc_attribute.module - Implements hook_node_update_index().
- _uc_attribute_alter_form in uc_attribute/
uc_attribute.module - Helper function for uc_attribute_form_alter().
- _uc_cart_product_get_options in uc_attribute/
uc_attribute.module - Gets the options chosen for a product that is in the cart.
File
- uc_attribute/
uc_attribute.module, line 1511 - Ubercart Attribute module.
Code
function _uc_attribute_get_name($attribute, $title = TRUE) {
if (!$title && $attribute->label == '<none>') {
return NULL;
}
else {
return empty($attribute->label) || $attribute->label == '<none>' && $title ? $attribute->name : $attribute->label;
}
}