Frage

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)

War es hilfreich?

Lösung

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; ?>

Andere Tipps

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.)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top