ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Radio Button conditional not working

December 17, 2010 1:14pm

Subscribe [3]
  • #1 / Dec 17, 2010 1:14pm

    sleven1868

    78 posts

    This question may be related to a resolved thread.

    So after making the change to the conditional as noted in the thread above.

    {if  {productline} == vector|helix|prism|matrix}

    Change to

    {if  {productline} == "vector|helix|prism|matrix"}

    The Error went away.  Now the value in the condition is false when I set the productline variable to “vector|helix|prism|matrix.”  If I change it back to the original it works but then the error from the related post returns.  “Notice: Use of undefined constant”  Can someone tell me why the conditional is false even though the value of the variable is exactly what its suppose to be for the condition to be true?  Thanks in advanced for any suggestions.

  • #2 / Dec 18, 2010 4:17pm

    Greg Salt

    3988 posts

    Hi sleven1868,

    If productline is a custom field then please remove the curly brackets from around it. Also, you posted that you set the productline variable to “vector|helix|prism|matrix.” - notice the fullstop after matrix. Was that a typo? I’m a bit unclear about this being a radio button conditional. Can you clarify where this data is coming from?

    Cheers

    Greg

  • #3 / Dec 20, 2010 11:22am

    sleven1868

    78 posts

    Hey greg,

    So I’m submitting a form that posts to itself and I use the IN function to grab the values and show data in weblog using dynamic paramters.  Here is the form code.

    <?php
    global $IN;
    $application = $IN->GBL('category','POST');
    $productline= $IN->GBL('weblog','POST');
    $wattage = $IN->GBL('wattage','POST');
    
    ?>  
    {assign_variable:productline="<?php echo $productline; ?>"}
    {assign_variable:application="<?php echo $application; ?>"}
    {assign_variable:wattage="<?php echo $wattage; ?>"}
    
    {embed="embeds/foxee_header"}
    
    <body>
    <div id="wrapper">
    {embed="embeds/banner"}
    {embed="embeds/main-nav"}
    <!-- start content -->
    
    
    
    
    
    
    <div id="shopbody">
             <div id="shopsearch">
                 <h2 class=shop-by"> shop by:</h2> {productline}
                 <div id="shopsearchlist">
                    <form action="{path='products/narrowresults'}" method="post">
                    {if  {productline} == "vector|helix|prism|matrix"}  
                            <input type="radio" name="weblog" value="vector|helix|prism|matrix">All Product Lines
    
                     {if:else}
                           <input type="radio" name="weblog" value="vector|helix|prism|matrix">All Product Lines
    
                     {/if}
    
                     {exp:weblog:categories weblog="vector|helix|prism|matrix" category_group="5" style="linear" show_empty="yes"}
                          {if category_name == "{productline}"}
                               <input type="radio" name="weblog" value="{category_name}">{category_url_title}
    
                          {if:else}
                                <input type="radio" name="weblog" value="{category_name}">{category_url_title}
    
                       {/if}
                     {/exp:weblog:categories}  
    
    
    
    
                     {if  {application} == 0 }
                          <input type="radio" name="category" value="0">All Applications
    
                    {if:else}
                          <input type="radio" name="category" value="0">All Applications
    
                    {/if}
                    {exp:weblog:categories weblog="vector" category_group="2" style="linear" show_empty="yes"}
                           {if category_id == {application} }
                                <input type="radio" name="category" value="{category_id}">{category_name}
    
                          {if:else}
                                <input type="radio" name="category" value="{category_id}">{category_name}
    
                          {/if}
                   {/exp:weblog:categories} 
    
    
    
    
    
                 {if {wattage} ==0}
                        <input type="radio" name="wattage"  value="0">All Wattages
    
                 {if:else}
                       <input type="radio" name="wattage" value="0">All Wattages
    
                 {/if}
                 {exp:weblog:categories weblog="vector|matrix" category_group="3" style="linear" show_empty="yes"}
                      {if category_id == {wattage} }
                          <input type="radio" name="wattage" value="{category_id}">{category_name}
    
                     {if:else}
                             <input type="radio" name="wattage" value="{category_id}">{category_name}
    
                     {/if}
                {/exp:weblog:categories}
    
              </form>
  • #4 / Dec 20, 2010 12:10pm

    sleven1868

    78 posts

    Hey Greg, another thing.  I have 2 instances of my test area running.  Both running the exact same code.  I use the old code for the product line as seen in my first post. I’m displaying the values of the variables right below the Shop By section in the radio group in the test.qnuru.com (broken instance)

    {if  {productline} == vector|helix|prism|matrix}

    Works for one instance, throws the Notice: Use of undefined constant error in the other.  You can see it happening using the following links. 
    http://test.qnuru.com/index.php/ShopbyProductLine/—>  Click on Helix and then click on “All Product Lines”—> Error

    http://vltest.qnuru.com/index.php/ShopbyProductLine/—>  Click on Helix and then click on “All Product Lines” —>  No Error

    When I change it to the new code in test.qnuru.com

    {if  {productline} == "vector|helix|prism|matrix"}

    The error goes away but then the conditional doesn’t become true when the value of the variable product_line is set to “vector|helix|prism|matrix”.  First, I can only speculate that its a server setting that is causing the error to be shown in one instance on one host but not in the other on another host.  It works on my old host even though I cannot see the error, which may or may not be there.  Hopefully this is a bit more information to help troubleshoot this issue.

  • #5 / Dec 21, 2010 2:51am

    John Henry Donovan

    12339 posts

    sleven1868,

    You may be running into a parsing issue by adding quotes now.
    Remove the quotes as you had them before. Your error reporting may show more on this server. So the error may have existed on your other server but you the errors were suppressed.

    These are errors I as a user cannot see. Only you as a Superadmin can see them. So if you revert code it will work for me as a user who is not going to see that error

    Or consider something like this which will bypass any parsing issues you have assigning a variable

    {if  "<?php echo $productline; ?>" == "vector|helix|prism|matrix"}
  • #6 / Dec 21, 2010 11:00am

    sleven1868

    78 posts

    Cool that works.  Thanks for the explanaintion.  I’m fairly new to EE so getting that helps me understand why things are happening.  As always, your support has been great.  This issue is resolved.  Thank you.

  • #7 / Dec 22, 2010 3:43am

    John Henry Donovan

    12339 posts

    Glad you are up and running again 😊 Feel free to start a new thread if you have any more questions.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases