Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 10th Aug 2012, 02:21 PM   #1
Active Warrior
 
Join Date: 2011
Posts: 58
Thanks: 9
Thanked 1 Time in 1 Post
Default
PHP Help Needed! Hiding custom attributes using 'IF" statement etc.
Share on: 
fb share twitter share gplus share more share

I am trying to hide 'no value' custom attributes on my magento frontend.

I am wondering if there is a way to hide the entire code if the 'singer' field (including attribute title) is emtpy on my magento backend?

I found a couple solutions online, i was able to hide the attribute value itself, but not the <b>Singer:</B> It seems to show no matter what.

This is what I have so far:

<b>Singer:</b> <?php echo $_product->getResource()->getAttribute('singer')->getFrontend()->getValue($_product) ?><br />
Thanks in advance.
Noobcorp is offline  
Unread 10th Aug 2012, 02:29 PM   #2
Feet of Fury
War Room Member
 
Hopeless Bromantic's Avatar
 
Join Date: 2012
Location: On your screen
Posts: 171
Thanks: 113
Thanked 183 Times in 138 Posts
Default
Re: PHP Help Needed! Hiding custom attributes using 'IF" statement etc.
Share on: 
fb share twitter share gplus share more share

Originally Posted by Noobcorp View Post

I am trying to hide 'no value' custom attributes on my magento frontend.

I am wondering if there is a way to hide the entire code if the 'singer' field (including attribute title) is emtpy on my magento backend?

I found a couple solutions online, i was able to hide the attribute value itself, but not the <b>Singer:</B> It seems to show no matter what.
Have you tried putting both items in a PHP echo call, and placing the echo calls inside a bracketed if statement?

I can't think of any reason that such an approach wouldn't work.

Good luck.

Bros find strictly platonic dudes on seekBromance.com
_______________________________________________
"It's pretty simple. You work hard, you believe anything is possible, and you try to make the world better."
Hopeless Bromantic is offline  
Unread 10th Aug 2012, 02:54 PM   #3
Active Warrior
 
Join Date: 2011
Posts: 58
Thanks: 9
Thanked 1 Time in 1 Post
Default
Re: PHP Help Needed! Hiding custom attributes using 'IF" statement etc.
Share on: 
fb share twitter share gplus share more share

sorry but I m really noob at this.
If its possible, can someone please modify my original code accordingly

Thank you very much in advance.
Noobcorp is offline  
Unread 10th Aug 2012, 03:26 PM   #4
Active Warrior
War Room Member
 
tomm's Avatar
 
Join Date: 2005
Posts: 96
Thanks: 11
Thanked 16 Times in 13 Posts
Default
Re: PHP Help Needed! Hiding custom attributes using 'IF" statement etc.
Share on: 
fb share twitter share gplus share more share

well it depends on what is the value that corresponds to empty, is it ""?

if so, you can try

if(!empty($_product->getResource()->getAttribute('singer')->getFrontend()->getValue($_product)))
{
?>
<b>Singer:</b> <?php echo $_product->getResource()->getAttribute('singer')->getFrontend()->getValue($_product) ?><br />
<?php
}
tomm is offline  
Unread 12th Aug 2012, 09:58 PM   #5
Active Warrior
 
Join Date: 2011
Posts: 87
Thanks: 16
Thanked 10 Times in 9 Posts
Default
Re: PHP Help Needed! Hiding custom attributes using 'IF" statement etc.
Share on: 
fb share twitter share gplus share more share

The <b>Singer:</b> is going to show no matter what. It's not within the php code. It's part of your html. So no matter what goes on with your script, the html will show up.

Need a QR Code? Check out my QR Code Generator. It's FREE!
dudeontheweb is offline  
Unread 13th Aug 2012, 11:21 AM   #6
Active Warrior
 
Join Date: 2011
Posts: 58
Thanks: 9
Thanked 1 Time in 1 Post
Default
Re: PHP Help Needed! Hiding custom attributes using 'IF" statement etc.
Share on: 
fb share twitter share gplus share more share

I got that going. Thanks guys.

Now i am experiencing something different;

This is what I have right now on my frontend (magento)- product view;

Code:
<?php echo "<b>Edition:</b> ".()->getAttributeText('edition')>
it is a custom attribute (drop down) with 3 choices;
Edition 1
Edition 2
Edition 3

I would like to make it possible so that if "edition 1" is selected on backend, it will show an image.

How can I possibily achieve something like that?

Thanks again
Noobcorp is offline  
Closed Thread


Bookmarks

Tags
statement


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 03:52 AM.