dimanche 24 mai 2020

Elseif statement does not execute

I'm trying to display the $attributevalue of a productpage from the Concrete5 Community store in a search block, hide if empty en diplay a other value if the result is not a product page. All works fine, except when the attribute of a productpage is empty. What It want to display is: "no attribute data". It now shows the list whitout the data.

I'm no programmer and don't know were it goes wrong. Does is has something to do with the result beeing NULL or 0?

<?php
   $product = \Concrete\Package\CommunityStore\Src\CommunityStore\Product\Product::getByCollectionID($r->getCollectionID());
   if ($product && (strlen(trim($attributevalue)) >= 0)){ 
   $attributevalue = $product->getAttribute('artikelnummer');?>
      <ul class="searchlist">
         <li><span>Artikel nr.:</span> <?php echo $attributevalue ; ?></li>
      </ul>
   <?php } 
   elseif ($product && (strlen(trim($attributevalue)) == 0)){
      echo 'no attribute data';
   } 
   else {
      echo 'no productpage';
   }
?>

Aucun commentaire:

Enregistrer un commentaire