What the {if} am I doing wrong?

This is a discussion on What the {if} am I doing wrong? within the v3.1 Modules & Modifications forums, part of the v3.1 Legacy Help & Support category; I'm trying to modify the code in step 3 of checkout to always list the items with ($0.00 ) cost ...


Go Back   68 Classifieds Forums > v3.1 Legacy Help & Support > v3.1 Modules & Modifications

 
LinkBack Thread Tools Display Modes
  #1  
Old 08-16-2008, 12:22 PM
Senior Member
 
Join Date: Sep 2006
Location: USA
Posts: 116
Rep Power: 12
Question What the {if} am I doing wrong?

I'm trying to modify the code in step 3 of checkout to always list the items with ($0.00 ) cost that are included in a package as the default choice in the drop down list. But, I want the choice to default to "No Thanks" if there is an addition charge for the item. That way the free features that are included in the package are always selected for the user during checkout and not the ones that require extra payment.

The code below is for the "featured ad" list box but the logic should apply to the "bold" and "Highlighted" drop down lists as well.

Could someone look at the code below and see why it won't work? It always drops to the 'else' options. I have only changed the code between the comments.

Thanks!

Code:
	{if $featured=="Y"}
	<tr>
          <td class="formleft">{$smarty.const.LANG_ADD_FEATURED}{$smarty.const.LANG_COLON}</td>
          <td class="formright">
			     ({$cFeaturedPrice}) <select name="featured">
           <!-- Default to free features -->
           {if $cFeaturedPrice=="$0.00 "}
    	      <option value="Y">{$smarty.const.LANG_YES} (+{$cFeaturedPrice})</option>
              <option value="N">{$smarty.const.LANG_NO_THANKS}</option>
          {else}
              <option value="N">{$smarty.const.LANG_NO_THANKS}</option>
              <option value="Y">{$smarty.const.LANG_YES} (+{$cFeaturedPrice})</option>
          {/if}
          <!-- END Default to free features -->
			</select>
		</td>
	</tr>
	{/if}


__________________
V3.1.5 Designer

"I have not failed. I've just found 10,000 ways that won't work."
THOMAS ALVA EDISON

Last edited by BigOrange; 08-16-2008 at 12:25 PM.
Reply With Quote
  #2  
Old 08-17-2008, 04:20 AM
sally_b's Avatar
Junior Member
 
Join Date: Nov 2007
Posts: 12
Rep Power: 5
Default

Hi. Maybe it is something to do with the $ and the extra blank space in the IF statement. Perhaps try

{if $cFeaturedPrice=="0.00"}
__________________

V3.1.10 Designer
www.ads-for-free.co.uk
Reply With Quote
  #3  
Old 08-17-2008, 10:42 AM
Senior Member
 
Join Date: Sep 2006
Location: USA
Posts: 116
Rep Power: 12
Default

Quote:
Originally Posted by sally_b View Post
Hi. Maybe it is something to do with the $ and the extra blank space in the IF statement. Perhaps try

{if $cFeaturedPrice=="0.00"}
If I output $cFeaturedPrice to the screen the output is $0.00 with what appears to be a space beside it when highlighted. But with the if statement set up that way it does not work.

Thanks for your help! Any other suggestions are welcomed.
__________________
V3.1.5 Designer

"I have not failed. I've just found 10,000 ways that won't work."
THOMAS ALVA EDISON
Reply With Quote
  #4  
Old 08-18-2008, 12:16 PM
68 Classifieds Staff
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,289
Rep Power: 98
Default

I would recommend putting {debug} var in that template then a smarty popup should appear with the value it is looking for.
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter
Reply With Quote
  #5  
Old 08-18-2008, 01:57 PM
Senior Member
 
Join Date: Sep 2006
Location: USA
Posts: 116
Rep Power: 12
Default

Quote:
Originally Posted by suzkaw View Post
I would recommend putting {debug} var in that template then a smarty popup should appear with the value it is looking for.
Thanks Eric for motivating me to get back on this. I had pretty much given up.

Here was the problem: {if $cFeaturedPrice=="$0.00"}
Here was the solution: {if $cFeaturedPrice=='$0.00'}

Using single quotes instead of double made it work correctly. I'm surprised I wasn't getting an error message.

Thanks for your help!
__________________
V3.1.5 Designer

"I have not failed. I've just found 10,000 ways that won't work."
THOMAS ALVA EDISON
Reply With Quote
  #6  
Old 08-18-2008, 02:07 PM
68 Classifieds Staff
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,289
Rep Power: 98
Default

Ahh yes. I didn't even look at the quotes.

With double quotes: "$0.00" it thinks the $ is a variable.
With single quotes: '$0.00' it doesn't.

You could probably also do this: "\$0.00" to escape the dollar sign.
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter
Reply With Quote
  #7  
Old 08-18-2008, 04:34 PM
Senior Member
 
Join Date: Sep 2006
Location: USA
Posts: 116
Rep Power: 12
Default

I have a similar problem with the function.new_listings.php plugin. I'm trying to show a camera icon if a listing has photos and nothing if the listing has no photos. The variable I'm trying to use is $entry.image but I'm not sure it is correct. The code I have added has comments that end in RLB.

If you can offer any help it would be appreciated.


Thanks for the great support!

PHP Code:
    $loop_count count($loop)-1;

    
$output "<table " $table_attr.">\n";
    for (
$x 0$x<= $loop_count$x++)
    {
        
//opening tr
        
$output .= "<tr" smarty_function_html_table_cycle_newlistings('tr',   $tr_attr$c) . ">\n";
        
//opening td
        
$output .= "<td class=\"newlist\"" smarty_function_html_table_cycle_newlistings('td',   $td_attr$c) . ">\n";
            
//title
            
if(defined('SEO'))
            {
                
$listing_title=$loop[$x][title];
                
$listing_title=str_replace(' ''_'$listing_title);
                
$listing_title=preg_replace('/\W/e'''$listing_title);
                
$output.="<a href='listing/".$loop[$x][id]."/".$listing_title.".html'>".$loop[$x][title]."</a>";
            }

            
// This is being used RLB
            
else
            {
             
// Check for photo in ad by RLB
               
if ($entry.image != " ")
               {
                  
$output.="<img src='/templates/default/images/ico_has_photo.jpg' align='left' width='18'> ";
               }
              else
              {
                  
$output.=" ";
              }
            
// END Check for photo in ad by RLB

              //ad title
              
$output.="<a href='viewlisting.php?view="$loop[$x][id] ."'>".$loop[$x][title]."</a>  ";
            }

              
//price
              
$output.="<center>"."<span style='font-size: 10px; color: #000000;'>".$loop[$x][price]."   (";
            
              
//date
              //$output.=smarty_modifier_date_format($loop[$x][dateadded], $date_format);

              // city
              
$output.=$loop[$x][city].")</span></center>";

              
// city
              // $output.=$loop[$x][state].")";

              //closing td
              
$output.="</td>\n";
              
$output .= "</tr>\n";
    }
    
$output .= "</table><br />\n"
__________________
V3.1.5 Designer

"I have not failed. I've just found 10,000 ways that won't work."
THOMAS ALVA EDISON

Last edited by BigOrange; 08-19-2008 at 07:45 PM.
Reply With Quote
  #8  
Old 08-18-2008, 05:07 PM
68 Classifieds Staff
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,289
Rep Power: 98
Default

I think this is your problem:
if ($entry.image != " ")

Should be:
if ($entry.image != "")
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter
Reply With Quote
  #9  
Old 08-18-2008, 05:57 PM
Senior Member
 
Join Date: Sep 2006
Location: USA
Posts: 116
Rep Power: 12
Default

That doesn't work either. I'm wondering if $entry.image is what I should be testing for.

When I try doing the opposite test [ if ($entry.image == "") ] the camera Icon never shows, even for ads that have photos. It's like I'm testing for the wrong variable or one that is not available in the function.new_listings.php plugin. Any other ideas why it doesn't work?

PHP Code:
// Check for photo in ad by RLB
               
if ($entry.image == "")
               {
                  
$output.="<img src='/templates/default/images/ico_has_photo.jpg' align='left' width='18'> ";
               }
              else
              {
                  
$output.=" ";
              }
            
// END Check for photo in ad by RLB 
__________________
V3.1.5 Designer

"I have not failed. I've just found 10,000 ways that won't work."
THOMAS ALVA EDISON
Reply With Quote
  #10  
Old 08-18-2008, 05:59 PM
68 Classifieds Staff
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,289
Rep Power: 98
Default

It will probably be easier if you just paste the whole file. I think what I need to see is not included with your first code paste.
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter
Reply With Quote

Bookmarks

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
My 68c modification story..Tell me if I'm wrong GPM55 Off Topic 16 04-18-2008 12:03 AM
does 68 classified have a wrong login time out lorenww v3.1 Questions & Support 5 10-12-2007 07:09 PM
Navigation points to the wrong directory BABBSELA v3.1 Questions & Support 9 11-16-2006 03:44 PM
Wrong status (active, inactive) for renewed ads with options pat01 v3.1 Questions & Support 0 07-29-2006 05:05 AM
Wrong email caused an error igor81 Off Topic 0 04-25-2006 08:21 AM


All times are GMT -4. The time now is 02:13 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22