1

I feel like this should be pretty simple, but I'm not getting the results that I want. I have an email signup form that displays across all my websites. If they happen to visit my website with the store code ama_br the email signup disappears. That is fine and that works. My elseif statement is a different form than the one that is displayed across all store views and I want this new form to only appear when it's store code ama_ca. It does not work for me and I don't see anything wrong with my code. Please help. Thank you.

            <?php if (Mage::app()->getStore()->getCode() != "ama_br"):?>
                <ul>
                    <li><?php echo $this->__('Email Sign Up')?></li>
                    <li>
                        <form action="<?php echo $this->getUrl('email_preferences')?>" method="get" id="newsletter-validate-detail">
                            <input name="email" type="text" id="newsletter" placeholder="<?php echo $this->__('Enter Email address')?>" title="<?php echo $this->__('Enter Email address')?>' class="required-entry validate-email">
                            <button class="submit">+</button>
                            <input type="hidden" name="source" value="nt">
                        </form>
                    </li>
                    <li class="footer-promo"><?php echo $this->getChildHtml('footer_promo')?></li>
                </ul>

            <?php elseif (Mage::app()->getStore()->getCode() == "ama_ca"):?>
                <ul>
                    <li><?php echo $this->__('Email Sign Up')?></li>
                    <li>
                <form method="post" action="http://enews.******.com/q/9MNK4U4iV9Mutb9YzTxF2zRWDIPgKoX0F0" accept-charset="UTF-8">
                        <input type="hidden" name="crvs" value="6hZNXcISD79ac2Empmsr2az_B3Qc5osTNmkOdNHleqhPIYmsxEOe6PbgaUo-3WBn_Vbgorrbk4qjekx7w4tljA">
                        <input type="hidden" name="CheckBox.Source.ca_footer" value="on">
                        <input name="email" type="text" id="newsletter" placeholder="Enter Email address" title="Enter Email address' class=" required-entry="">
                        <input type="hidden" id="submit" value="Sign Up">
                        </form>
                    </li>
                    <li class="footer-promo"><?php echo $this->getChildHtml('footer_promo')?></li>
                </ul>
            <?php endif;?>
4
  • 2
    logic. only ONE block of an if will execute. since you're doing a != test in the first one, then 'ama_ca' != 'ama_br' is TRUE, and that block executes, skipping ENTIRELLY the == 'ama_ca' one that follows. Commented Oct 6, 2016 at 19:49
  • Put the check for ama_ca first. Commented Oct 6, 2016 at 20:02
  • @ thismethod refer to my answer it will resolve your query Commented Oct 6, 2016 at 20:20
  • Thanks @MarcB, i wasn't aware of how that logic was working. Thank you. *noted Commented Oct 6, 2016 at 20:21

1 Answer 1

1

Description You have done every thing right but you just miss the trick look carefully on your if statement Logic that is if your Code not equals to ama_br that is it can be equal to ama_ca so it will show the form in if statement for ama_ca as well as on any other string from ama_br so the form you are trying to show on Code equals to ama_ca is not showing. Try one of the following it will resolve your query.

Code

        <?php if (Mage::app()->getStore()->getCode() == "ama_ca"): ?>
          <ul>
            <li><?php echo $this->__('Email Sign Up') ?></li>
            <li>
            <form method="post" action="http://enews.******.com/q/9MNK4U4iV9Mutb9YzTxF2zRWDIPgKoX0F0" accept-charset="UTF-8">
            <input type="hidden" name="crvs" value="6hZNXcISD79ac2Empmsr2az_B3Qc5osTNmkOdNHleqhPIYmsxEOe6PbgaUo-3WBn_Vbgorrbk4qjekx7w4tljA">
            <input type="hidden" name="CheckBox.Source.ca_footer" value="on">
            <input name="email" type="text" id="newsletter" placeholder="Enter Email address" title="Enter Email address' class=" required-entry="">
            <input type="hidden" id="submit" value="Sign Up">
            </form>
            </li>
           <li class="footer-promo"><?php echo $this->getChildHtml('footer_promo') ?></li>
         </ul>

        <?php elseif (Mage::app()->getStore()->getCode() != "ama_br"): ?>
          <ul>
            <li><?php echo $this->__('Email Sign Up') ?></li>
            <li>
              <form action="<?php echo $this->getUrl('email_preferences') ?>" method="get" id="newsletter-validate-detail">
              <input name="email" type="text" id="newsletter" placeholder="<?php echo $this->__('Enter Email address') ?>" title="<?php echo $this->__('Enter Email address') ?>' class="required-entry validate-email">
                   <button class="submit">+</button>
              <input type="hidden" name="source" value="nt">
              </form>
              </li>
              <li class="footer-promo"><?php echo $this->getChildHtml('footer_promo') ?></li>
             </ul>
        <?php endif; ?>

OR

       <?php if (Mage::app()->getStore()->getCode() != "ama_br" && Mage::app()- >getStore()->getCode() != "ama_ca"): ?>
          <ul>
           <li><?php echo $this->__('Email Sign Up') ?></li>
            <li>
            <form action="<?php echo $this->getUrl('email_preferences') ?>" method="get" id="newsletter-validate-detail">
            <input name="email" type="text" id="newsletter" placeholder="<?php echo $this->__('Enter Email address') ?>" title="<?php echo $this->__('Enter Email address') ?>' class="required-entry validate-email">
                   <button class="submit">+</button>
                   <input type="hidden" name="source" value="nt">
            </form>
       </li>
       <li class="footer-promo"><?php echo $this->getChildHtml('footer_promo') ?></li>
      </ul>

      <?php elseif (Mage::app()->getStore()->getCode() == "ama_ca"): ?>
      <ul>
          <li><?php echo $this->__('Email Sign Up') ?></li>
      <li>
        <form method="post" action="http://enews.******.com/q/9MNK4U4iV9Mutb9YzTxF2zRWDIPgKoX0F0" accept-charset="UTF-8">
            <input type="hidden" name="crvs" value="6hZNXcISD79ac2Empmsr2az_B3Qc5osTNmkOdNHleqhPIYmsxEOe6PbgaUo-3WBn_Vbgorrbk4qjekx7w4tljA">
            <input type="hidden" name="CheckBox.Source.ca_footer" value="on">
            <input name="email" type="text" id="newsletter" placeholder="Enter Email address" title="Enter Email address' class=" required-entry="">
            <input type="hidden" id="submit" value="Sign Up">
        </form>
    </li>
       <li class="footer-promo"><?php echo $this->getChildHtml('footer_promo')  ?></li>
    </ul>
    <?php endif; ?>
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you @Ahmer. I'm using the first answer based on how the logic works and less code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.