0

PHP code not running in /header.phtml I have the following code in /app/design/frontend/default/gumball/template/page/html/header.phtml

<li class="my-cart">
<a href="<?php echo $this->getUrl('checkout/cart/')?>" class="cartcount cartlink">

<? if(Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty() > 0) { ?>
<?=__(Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty())?> 
    <? } else { ?>
    0 
 <? } ?> Item(s)

  </a>
</li>

On the current server the Correct html being produced is

<li class="my-cart">
   <a href="http://www.gumball-machine.com/checkout/cart/" class="cartcount cartlink">
   0 Item(s)</a>

but on the other server that I am trying to move the current site to I get the following html

<li class="my-cart">
<a href="http://www.ecandymachine.com/checkout/cart/" class="cartcount cartlink">
<? if(Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty() > 0) { ?>
<?=__(Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty())?> 
<? } else { ?>
0 
<? } ?> Item(s)
  </a>

It seems that the php code is not running. What can I do to resolve this issue?

Thanks.

1 Answer 1

2

This is not a magento issue. It's a server configuration "issue".
Most likely short tags are not enabled on you server. Change your code into this and it should work regardless of the short tags settings.

<li class="my-cart">
<a href="<?php echo $this->getUrl('checkout/cart/')?>" class="cartcount cartlink">

<?php if(Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty() > 0) { ?>
<?php echo __(Mage::getSingleton('checkout/session')->getQuote()->getItemsSummaryQty())?> 
    <?php } else { ?>
    0 
 <?php } ?> Item(s)

  </a>
</li>

A bit off topic:
read more guidelines on how to write magento code. Your issue is listed in there also.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.