Help met PHP error spotten

Status
Niet open voor verdere reacties.

julianmurillo

Gebruiker
Lid geworden
15 jan 2018
Berichten
41
Hallo allemaal

Voor Magento ben ik bezig met het plaatsen van twee functies, die een stukje code zouden uitvoeren; de code retourneert geen syntax errors; maar tijdens het 'display' van de template krijg ik een 500 error (wit scherm). Hebben jullie misschien een idee waar het mis lijkt te gaan? Zonder de code te hebben gezet in functies, werkt het wel, maar ik dacht dat het beter zou zijn om de code zo optimaal mogelijke te houden. De code is als volgt:

PHP:
<?php

$objectManager      = \Magento\Framework\App\ObjectManager::getInstance();
$product            = $objectManager->get('Magento\Framework\Registry')->registry('current_product');

$offertelink        = $product->getData('offerte_link');
$image              = $block->getUrl('pub/media/catalog').'product'.$product->getData('grootmateriaal_extra_image_int');

$_categoryHelper    = $this->helper('Custom\Config\Helper\Category');
$_productHelper     = $this->helper('Custom\Config\Helper\Product');

$attributes = array_slice(explode(',', $_categoryHelper->getCurrentCategoryData('category_attributes')),0, 6);
$getIconsValues = $product->getResource()->getAttribute('icons')->getFrontend()->getValue($product);

function getCategoryAttributes($_categoryHelper) {

        if($_categoryHelper->getCurrentCategoryData('category_attributes')):
            foreach($attributes as $attr):
            $attr = $_productHelper->getAttributeByCode(trim($attr));

            echo '<div class="pd-icon pd-icon-'.$attr.'">';
                echo $_productHelper->getAttributeText($product, $attr);
            echo '</div>';

        endforeach; endif;

        echo '<div class="pd-icon-button-container">';
            echo '<a class="button large cta" href="<?php echo $offertelink; ?>"><span>';
            echo __('Ask');
            echo '</span></a>';
        echo '</div>';

        echo '<div class="pd-icon-button-container">';
            echo '<a class="button open" href="#amasty-downloads"><span>';
            echo __('Download');
            echo '</span></a>';
        echo '</div>';

        if ($image):
            echo '<div class="pd-icon-image-container">';
                echo '<img src="'.$image.'" alt="">';
            echo '</div>';
        endif;
}

function getProductAttributes($_categoryHelper) {
    $iconen_array = explode(',', $getIconsValues);
        foreach($iconen_array as $a):
            echo '<div class="pd-icon pd-icon-'.strtolower(trim($a)).'">';
            $attr = $product->getResource()->getAttribute(strtolower(trim($a)));
            echo $attr->getFrontend()->getValue($product);
            echo '</div>';
        endforeach;
}

?>

<div class="pd-icon-container">

<?php if($product->hasData('icons')): ?>

    <?php if ( empty ($getIconsValues) ):
        getCategoryAttributes($objectManager); ?>

    <?php else:
        getProductAttributes($objectManager); ?>
    <?php endif; ?>

<?php else:
    getCategoryAttributes($objectManager); ?>

<?php endif; ?>

</div>
 
Heb je al in de error_log gekeken?
Welk webhosting control-panel gebruik je?
Vraag anders je webhosting eens waar je die kan vinden.
 
Laatst bewerkt:
Hallo allemaal
template ... een 500 error (wit scherm). ...:

PHP:
<?php
--
28            echo '<a class="button large cta" href="<?php echo $offertelink; ?>"><span>';
--
Nu het lijkt mijn een selfprotectionservice of een soort geheugen (cash) van de volledig pagina waarna er word gekeken of er <?php in voor komt dit ter protectie dat een stuk code zichtbaar wordt geplaats door een fout van de programmeur...

Code:
<?php
$objectManager      = \Magento\Framework\App\ObjectManager::getInstance();
$product            = $objectManager->get('Magento\Framework\Registry')->registry('current_product');
$offertelink        = $product->getData('offerte_link');
$image              = $block->getUrl('pub/media/catalog').'product'.$product->getData('grootmateriaal_extra_image_int');
$_categoryHelper    = $this->helper('Custom\Config\Helper\Category');
$_productHelper     = $this->helper('Custom\Config\Helper\Product');
$attributes = array_slice(explode(',', $_categoryHelper->getCurrentCategoryData('category_attributes')),0, 6);
$getIconsValues = $product->getResource()->getAttribute('icons')->getFrontend()->getValue($product);
function getCategoryAttributes($_categoryHelper) {
        if($_categoryHelper->getCurrentCategoryData('category_attributes')):
            foreach($attributes as $attr):
            $attr = $_productHelper->getAttributeByCode(trim($attr));
            echo '<div class="pd-icon pd-icon-'.$attr.'">';
                echo $_productHelper->getAttributeText($product, $attr);
            echo '</div>';
        endforeach; endif;
        echo '<div class="pd-icon-button-container">';
            echo '<a class="button large cta" href="'. $offertelink.'"><span>';
            echo __('Ask');
            echo '</span></a>';
        echo '</div>';
        echo '<div class="pd-icon-button-container">';
            echo '<a class="button open" href="#amasty-downloads"><span>';
            echo __('Download');
            echo '</span></a>';
        echo '</div>';
        if ($image):
            echo '<div class="pd-icon-image-container">';
                echo '<img src="'.$image.'" alt="">';
            echo '</div>';
        endif;
}
function getProductAttributes($_categoryHelper) {
    $iconen_array = explode(',', $getIconsValues);
        foreach($iconen_array as $a):
            echo '<div class="pd-icon pd-icon-'.strtolower(trim($a)).'">';
            $attr = $product->getResource()->getAttribute(strtolower(trim($a)));
            echo $attr->getFrontend()->getValue($product);
            echo '</div>';
        endforeach;
}
?>
<div class="pd-icon-container">
<?php 
if($product->hasData('icons')){
         if( empty($getIconsValues) ){      getCategoryAttributes($objectManager); }
         else{                              getProductAttributes($objectManager);  }
} else{                                     getCategoryAttributes($objectManager); }
?>
</div>
 
Heb je al geprobeerd een deel van de code als comment te markeren (met /* ... */) en zo de fout te localiseren, zodat je geen witte pagina krijgt?
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan