Reputation: 911
we have custom dropdown attribute with values : "YES" or "NO" in backend.
I want to display the text in view page only if value = "yes"
attribute code : name_order . below is code.
<?php echo "display text"; ?>
Upvotes: 0
Views: 2883
Reputation: 5118
I'm assuming it's a product attribute?
If so, you can get value of your attribute per product by using the getAttributeText()
method.
<?php
if($_product->getAttributeText("name_order") == "Yes") {
echo "Set to Yes";
} else {
echo "Set to No";
}
?>
Upvotes: 1
Reputation: 5174
I assume you mean the template app/design/frontend/default/<YOUR THEME>/template/catalog/product/view.phtml
and you implemented the attribute correctly you can access it via
$_product->getNameOrder()
Upvotes: 1
Reputation: 191
Go Admin -> Catalog -> Attributes -> Manage Attributes
Set "Used in Product View page" to Yes
Then in view.phtml :
if($_product->getAttributeText('name_order')=='yes')
{
echo "display text";
}
Upvotes: 1