0

I have just moved my site onto a live server and everything is working, all except the view.phtml for the product page. (catalog/product/view.phtml) This is an edited file but even the default theme file throws me the same problem. Any help would be seriously appreciated. My main focus is the first broken section. I can deal without the rest or recreate them but the first one I don't really understand how I made it work I just know I took a guess and it works.

The file shows no errors at all on my localhost but on the live server it gives me the error HP Parse error: syntax error, unexpected end of file in /catalog/product/view.phtml on line 556, referer: URL the error happens on (what ever product page I load.

Checking the file the Line just shows the very last line in the code which is just a DIV however I found the 3 pieces of code that cause the issue. I just cannot understand why they are causing a parsing error or how to fix it.

The 3 blocks of code are as follows. (see full page here) Block 1:

                            <?php $custom = $_product->getcustom(); ?>
                                <?php if (trim($custom == 28)); ?>    
                                    <div class="customproducttxt"> 
                                        <?php echo "Design your own Label by clicking the thumbnail below or if you want to add a more personal touch, enter your message below and we will hand write the message!"; ?>
                                    </div>

                                <?php elseif (trim($custom == 29)); ?>     
                                    <div class="customproducttxt">
                                        <?php echo "Click on the thumbnail below and start designing your own personalised message!";?>
                                    </div>
                                <?php endif; ?>

Block 2:

    <?php $iftasting = $_product->gettastingnotes(); ?>
            <?php if (trim($iftasting !== false)): ?>    
                 <div class="box-collateral_region">
                    <h2><?php echo "Tasting Notes" ; ?></h2>
                            <div class="box-collateral">
                                <div class="tasting-txt">
                                           <?php echo $_helper->productAttribute($_product, nl2br($_product->getTastingnotes()), 'tastingnotes') ;?>
                                </div>
                            </div>
                 </div>
            <?php endif; ?>

Block 3:

getAttributeText('manufacturer'); ?>
<?php $ifmanufactuer = $_product->getmanufacturer(); ?>
        <?php if (trim($ifmanufacturer !== false)): ?>    
             <div class="box-collateral_manufacturer">
                <h2><?php echo "Distillery" ; ?></h2>
                        <div class="box-collateral">
                            <div class="manufacturer-img">
                                <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'manufacturer/' . $manufacturer . ".png"; ?>" data-srcX2="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'manufacturer/' . $manufacturer . '@x2' . ".png"; ?>" alt="" >
                            </div>

                            <div class="manufacturer-txt">
                                        <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId($manu)->toHtml() ?>
                            </div>
                        </div>
             </div>
        <?php endif; ?>

I have tried a few changes to see what happens but the only thing that I managed to get to work was the top if I changed : to ; and removed the elseif and endif (making it useless)

2 Answers 2

0

I am not sure but when we use

if(trim($a==$b)) if condition satisfy then it respond with string(1) "1" may be that cause problem.

but you can use trim as follows for all 3 blocks.

Block 1

If custom contains integer value the do not need trim i think.

<?php $custom = $_product->getcustom(); ?>
<?php if (trim($custom) == 28): ?>    
    <div class="customproducttxt"> 
        <?php echo "Design your own Label by clicking the thumbnail below or if you want to add a more personal touch, enter your message below and we will hand write the message!"; ?>
    </div>

<?php elseif (trim($custom) == 29): ?>     
    <div class="customproducttxt">
        <?php echo "Click on the thumbnail below and start designing your own personalised message!";?>
    </div>
<?php endif; ?>
  

Block 2

<?php $iftasting = $_product->gettastingnotes(); ?>
<?php if (trim($iftasting) !== false): ?>    
     <div class="box-collateral_region">
        <h2><?php echo "Tasting Notes" ; ?></h2>
                <div class="box-collateral">
                    <div class="tasting-txt">
                               <?php echo $_helper->productAttribute($_product, nl2br($_product->getTastingnotes()), 'tastingnotes') ;?>
                    </div>
                </div>
     </div>
<?php endif; ?>

Block 3

<?php $ifmanufactuer = $_product->getmanufacturer(); ?>
<?php if (trim($ifmanufacturer) !== false): ?>    
     <div class="box-collateral_manufacturer">
        <h2><?php echo "Distillery" ; ?></h2>
                <div class="box-collateral">
                    <div class="manufacturer-img">
                        <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'manufacturer/' . $manufacturer . ".png"; ?>" data-srcX2="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'manufacturer/' . $manufacturer . '@x2' . ".png"; ?>" alt="" >
                    </div>

                    <div class="manufacturer-txt">
                                <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId($manu)->toHtml() ?>
                    </div>
                </div>
     </div>
<?php endif; ?>
1
  • The brackets! That is what the problem was, thank you for pointing these out to me. I had fixed block 2 and 3 already using a different method but now I know how to use the trim correctly without the issue reappearing. (can finally launch the site now, thanks again!)
    – Francis
    Sep 10, 2014 at 12:46
0

Found the answer to Block 1!

I changed it to

                    <?php $custom = $_product->getcustom(); ?>

                    <?php if($custom == '28'): ?>
                        <div class="customproducttxt"> 
                            <?php echo "Design your own Label by clicking the thumbnail below or if you want to add a more personal touch, enter your message below and we will hand write the message!"; ?>
                        </div>
                    <?php elseif($custom == '29'): ?>
                        <div class="customproducttxt">
                            <?php echo "Click on the thumbnail below and start designing your own personalised message!";?>
                        </div>
                    <?php endif; ?>

I am still not sure what the syntax/parsing error actually was but just changing it to avoiding the trim method let me work around it (Or I have fixed it without noticing.)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.