Probleme mit PHP Code

Fallout

Grünschnabel
Hallo,
hoffe Ihr könnt mir weiterhelfen.

Benutze einen opensource Shop und habe bei der Produktaufluistung etwas am Code geändert.

Nun kann man über den Adminbereich das Style ändern.
Mittels elseif abfrage wird der Style zugeordnet.

Nun habe ich das Problem das er das elseif nicht richtig zuweist oder beide Anzeigt.

Wie könnte ich am besten die 3 Optionswerte am besten auseinander halten

Hier mal ein Textschnippsel
Code:
<?php
  }


                                                                   Option 1
-----------------------------------------------------------------------------------------------------------------------------------------------
                              if (PRODUCT_LISTING_DISPLAY_STYLE == 'list') {
-----------------------------------------------------------------------------------------------------------------------------------------------


    $info_box_contents = array();
    if ($listing_split->number_of_rows > 0) {
      $row = 0;
      $col = 0;
      $listing_query = tep_db_query($listing_split->sql_query);
      while ($listing = tep_db_fetch_array($listing_query)) {
        $listing['products_name'] = tep_get_products_name($listing['products_id']);
        
        if (PRODUCT_LIST_IMAGE > 0) {
	      $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br>';
        }
          
        if (PRODUCT_LIST_NAME > 0) {
	      $lc_text .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br>';
        }

        if (PRODUCT_LIST_MODEL > 0) {
	      $lc_text .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . $listing['products_model'] . '</a><br>';
        }

        if (PRODUCT_LIST_MANUFACTURER > 0) {
	      $lc_text .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a><br>';
        }

        if (PRODUCT_LIST_PRICE > 0) {
          if (tep_not_null($listing['specials_new_products_price'])) {
            $lc_text .= '<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>&nbsp;&nbsp;<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>';
          } else {
            $lc_text .= '&nbsp;' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '&nbsp;';
          }
        }

        if (PRODUCT_LIST_BUY_NOW) {
          $lc_text .= '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing['products_name'] . TEXT_NOW) . '</a>';   	  
        }

        $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"',
                                                'text' => $lc_text);

        $col ++;
        if ($col > PRODUCT_LIST_COL_NUM-1) {
          $col = 0;
          $row ++;
        }
      }

      new contentBox($info_box_contents);

    } else {

      $info_box_contents = array();

      $info_box_contents[0] = array('params' => 'class="productListing-odd"');
      $info_box_contents[0][] = array('params' => 'class="productListing-data"',
                                        'text' => TEXT_NO_PRODUCTS);

      new contentBox($info_box_contents);

    }







                                                                   Option 2
-----------------------------------------------------------------------------------------------------------------------------------------------
                             } elseif (PRODUCT_LISTING_DISPLAY_STYLE == 'style1') {
-----------------------------------------------------------------------------------------------------------------------------------------------





if ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW' &&
$column_list[$col] != 'PRODUCT_LIST_IMAGE' &&
$column_list[$col] != 'PRODUCT_LIST_DESCRIPTION')
$lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);

if ($column_list[$col] != 'PRODUCT_LIST_DESCRIPTION') {
$list_box_contents[0][] = array('align' => $lc_align,
'params' => 'class="productListing-heading"',
'text'  => "&nbsp;" . $lc_text . "&nbsp;");
}
}

if ($listing_split->number_of_rows > 0) {
$rows = 0;
$listing_query = tep_db_query($listing_split->sql_query);
while ($listing = tep_db_fetch_array($listing_query)) {
$rows++;
if (($rows/2) == floor($rows/2)) {
$list_box_contents[] = array('params' => 'class="productListing-even"');
} else {
$list_box_contents[] = array('params' => 'class="productListing-odd"');
}
$cur_row = sizeof($list_box_contents) - 1;
for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
$lc_align = '';

$lc_params = '';


switch ($column_list[$col]) {
case 'PRODUCT_LIST_MODEL':
$lc_align = '';
$lc_text_product_model = '       ' . $listing['products_model'] . '&nbsp;';
break;

case 'PRODUCT_LIST_NAME':
$lc_align = '';
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
$lc_text_product_name = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
} else {
$lc_text_product_name = '&nbsp;<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>&nbsp;';
}
break;


case 'PRODUCT_LIST_DESCRIPTION':
$lc_text_short_description = '     ' . osc_trunc_string(strip_tags($listing['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . '  ';
$col_to_span = sizeof($column_list)-1;
if (PRODUCT_LIST_IMAGE > 0) {
$col_to_span -= 1;
}
$lc_params = 'colspan="' . $col_to_span . '" ';
break;


case 'PRODUCT_LIST_MANUFACTURER':
$lc_align = '';
$lc_text_manufacturer = '     <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a>&nbsp;';
break;

case 'PRODUCT_LIST_PRICE':
$lc_align = 'right';
if (tep_not_null($listing['specials_new_products_price'])) {
//GroupDiscount start
$lc_text_product_price = '       <span class="productSpecialPrice">' . $currencies->display_price_nodiscount($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span><br><span class="productSpecialPrice3">statt vorher</span><br><s><span class="productSpecialPrice2">' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span></s>';
//$lc_text_product_price = '      <s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>&nbsp;aa&nbsp;<span class="productSpecialPrice">' . $currencies->display_price_nodiscount($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>&nbsp;';
//GroupDiscount end
} else {
$lc_text_product_price = '           ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '&nbsp;';
}
break;

case 'PRODUCT_LIST_QUANTITY':
$lc_align = 'right';
$lc_text_product_quantity = 'Lagerbestand:<br>' . $listing['products_quantity'] . '<br>';
break;

case 'PRODUCT_LIST_WEIGHT':
$lc_align = 'right';
$lc_text_product_weight = 'Produktgewicht:<br>' . $listing['products_weight'] . 'kg>';
break;

case 'PRODUCT_LIST_IMAGE':
$lc_align = 'center';
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
$lc_text_product_image = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
} else {
$lc_text_product_image = '&nbsp;<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>&nbsp;';
}

if (PRODUCT_LIST_DESCRIPTION > 0) {
$lc_params = 'rowspan="2" ';
}

break;

case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
$lc_text_product_buy_now = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>&nbsp;';
break;

case 'PRODUCT_SORT_ORDER';
$lc_align = 'center';
$lc_text = '&nbsp;' . $listing['products_sort_order'] . '&nbsp;';
break;
}

$list_box_contents[$cur_row][] = array('align' => $lc_align,
'params' => 'class="productListing-data"',
'text'  => $lc_text);
}

echo("

<tr>
<td>
<table class=\"katbox\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">
<tr>
<td class=\"katboxInfoBoxHeading\" align=\"left\"> " . $lc_text_product_name  . "</td>
</tr>
<tr>
<td>
<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td class=\"main\" width=\"10%\" align=\"center\">                " .  CENTER_BILD  . "</td>
<td class=\"main\" width=\"90%\" colspan=\"2\">                   " . CENTER_KURZ  . "</td>
</tr>
<tr>
<td class=\"main\" width=\"10%\">                                           " . $lc_text_product_image  . "</td>
<td class=\"main\" width=\"90%\" colspan=\"2\"><p align=\"justify\">          " . $lc_text_short_description   . "   </td>
</tr>
<tr>
<td class=\"main\" width=\"10%\" align=\"center\">&nbsp;</td>
<td class=\"main\" width=\"50%\">&nbsp;</td>
<td class=\"price1\" width=\"40%\" rowspan=\"3\" align=\"center\">              " . TEXT_PRICE  . "<b><font size=\"4\">         " . $lc_text_product_price  . "</font></b></td>
</tr>
<tr>
<td class=\"main\" width=\"10%\" align=\"center\">                   " . TEXT_MANUFACTURER  . "</td>
<td class=\"main\" width=\"50%\">                      " . CENTER_MODEL  . "</td>
</tr>
<tr>
<td class=\"main\" width=\"10%\" valign=\"top\" align=\"center\">                    " . $lc_text_manufacturer  . "</td>
<td class=\"main\" width=\"50%\" valign=\"top\">                            " . $lc_text_product_model  . "</td>
</tr>
<tr>
<td class=\"main\" width=\"10%\" align=\"center\">
<?php echo $lc_text_product_quantity; ?>
<?php echo $lc_text_product_weight; ?>
</td>
<td class=\"main\" width=\"50%\">&nbsp;</td>
<td class=\"main\" width=\"40%\" valign=\"top\" align=\"center\">   " . $lc_text_product_buy_now  . "</td>
</table>
</td>
</tr
</form>
</table></td>
</tr>



");


    }

    }








    
  if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
    <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
    <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  </tr>
</table>
<?php
  }
?>


Es soll also entweder nur der Options wert 1 oder nur der 2te ausgegeben werden. Momentan wird bei Option 1 der 2te direkt darunter dargestellt. Wählt man Option 2 über den Admin, funktioniert es.

LG Fallout
 
Zuletzt bearbeitet:
PHP:
if(bedingung1){//Trifft Fall1 zu, mache dies
}
if(bedingung1){//Trifft Fall1 zu, mache dies
}
elseif(bedingung2){//trifft Fall1 nicht zu, aber Fall2, mache das
}
elseif(bedingung3){//treffen Fall1 und Fall2 nicht zu, aber Fall3, mache das
}
else{//trifft überhaupt nix zu, tu jenes
}
 
Zuletzt bearbeitet:
Hallo fatalus,

danke für deine schnelle Antwort.

Leider bringt mich das nicht weiter. Hab das ja so wie du beschrieben hast.

Hier nochmal der Code, etwas übersichtlicher.
Code:
<table border="0" width="100%" cellspacing="0" cellpadding="2"> 


CUUUUUUUUUUUUUUUUUUTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 


</table> 


<?php } 
//                       (Option 1 - LIST) 
//----------------------------------------------------------------------------------- 
if (PRODUCT_LISTING_DISPLAY_STYLE == 'list') { 
//----------------------------------------------------------------------------------- 
//                       (Option 1 - LIST) 

  $list_box_contents = array(); 

  for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { 
    switch ($column_list[$col]) { 
      case 'PRODUCT_LIST_MODEL': 
        $lc_text = TABLE_HEADING_MODEL; 
        $lc_align = ''; 
        break; 




CUUUUUUUUUUUUUUUUUUTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 



            $lc_align = 'center'; 
            $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>&nbsp;'; 
            break; 
          case 'PRODUCT_SORT_ORDER'; 
            $lc_align = 'center'; 
            $lc_text = '&nbsp;' . $listing['products_sort_order'] . '&nbsp;'; 
            break; 
        } 

        // Products Description Hack begins 
        $lc_params .= 'class="productListing-data"'; 
        if ($column_list[$col] == 'PRODUCT_LIST_DESCRIPTION') { 
          $list_box_contents[$cur_row][] = array('align' => $lc_align, 
                                                 'params' => $lc_params, 
                                                 'text' => $lc_text, 
                                                 'desc_flag' => 'true'); 
        } else { 
          $list_box_contents[$cur_row][] = array('align' => $lc_align, 
                                                 'params' => $lc_params, 
                                                 'text'  => $lc_text); 
        } 
        // Products Description Hack ends 

      } 
    } 

    new productListingBox($list_box_contents); 
  } else { 
    $list_box_contents = array(); 

    $list_box_contents[0] = array('params' => 'class="productListing-odd"'); 
    $list_box_contents[0][] = array('params' => 'class="productListing-data"', 
                                   'text' => TEXT_NO_PRODUCTS); 

      new productListingBox($list_box_contents); 
    } 





//                            (Option 2 - Columns) 
//-------------------------------------------------------------------------------------------------- 
} elseif (PRODUCT_LISTING_DISPLAY_STYLE == 'columns') { 
//-------------------------------------------------------------------------------------------------- 
//                            (Option 2 - Columns) 


    $info_box_contents = array(); 
    if ($listing_split->number_of_rows > 0) { 
      $row = 0; 
      $col = 0; 
      $listing_query = tep_db_query($listing_split->sql_query); 
      while ($listing = tep_db_fetch_array($listing_query)) { 
        $listing['products_name'] = tep_get_products_name($listing['products_id']); 
        


CUUUUUUUUUUUUUUUUUUTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 



        $col ++; 
        if ($col > PRODUCT_LIST_COL_NUM-1) { 
          $col = 0; 
          $row ++; 
        } 
      } 

      new contentBox($info_box_contents); 

    } else { 

      $info_box_contents = array(); 

      $info_box_contents[0] = array('params' => 'class="productListing-odd"'); 
      $info_box_contents[0][] = array('params' => 'class="productListing-data"', 
                                        'text' => TEXT_NO_PRODUCTS); 

      new contentBox($info_box_contents); 

    } 





//                              (Option 3 - Style1) 
//---------------------------------------------------------------------------------------------- 
} elseif (PRODUCT_LISTING_DISPLAY_STYLE == 'style1') { 
//--------------------------------------------------------------------------------------------- 
//                              (Option 3 - Style1) 

switch ($column_list[$col]) { 
case 'PRODUCT_LIST_MODEL': 
$lc_align = ''; 
$lc_text_product_model = '       ' . $listing['products_model'] . '&nbsp;'; 
break; 

case 'PRODUCT_LIST_NAME': 
$lc_align = ''; 
if (isset($HTTP_GET_VARS['manufacturers_id'])) { 
$lc_text_product_name = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>'; 
} else { 
$lc_text_product_name = '&nbsp;<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>&nbsp;'; 
} 
break; 

// Products Description Hack begins 
case 'PRODUCT_LIST_DESCRIPTION': 
$lc_text_short_description = '     ' . osc_trunc_string(strip_tags($listing['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . '  '; 
$lc_text_read_more = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . TEXT_MORE . '</a>'; 
$col_to_span = sizeof($column_list)-1; 
if (PRODUCT_LIST_IMAGE > 0) { 
$col_to_span -= 1; 
} 
$lc_params = 'colspan="' . $col_to_span . '" '; 
break; 



CUUUUUUUUUUUUUUUUUUTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 




$list_box_contents[$cur_row][] = array('align' => $lc_align, 
'params' => 'class="productListing-data"', 
'text'  => $lc_text); 
} 

echo(" 

<tr> 
<td> 
<table class=\"katbox\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\"> 
<tr> 
<td class=\"katboxInfoBoxHeading\" align=\"left\">     " . $lc_text_product_name  . "     </td> 


CUUUUUUUUUUUUUUUUUUTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT 


<td class=\"main\" width=\"10%\" valign=\"top\" align=\"center\">     " . $lc_text_manufacturer  . "     </td> 
<td class=\"main\" width=\"50%\" valign=\"top\">     " . $lc_text_product_model  . "     </td> 
</tr> 
<tr> 
<td class=\"main\" width=\"10%\" align=\"center\"> 
     " . $lc_text_product_quantity  . " 
     " . $lc_text_product_weight  . " 
</td> 
<td class=\"main\" width=\"50%\">&nbsp;</td> 
<td class=\"main\" width=\"40%\" valign=\"top\" align=\"center\">     " . $lc_text_product_buy_now  . "     </td> 
</table> 
</td> 
</tr 
</form> 
</table></td> 
</tr> 
"); 

  } 

  } 

  if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) { 
?> 



<tr> 
<td colspan="<?php echo $colspan; ?>"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 
  <tr> 
    <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td> 
    <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td> 
  </tr> 
</table></td> 
</tr> 
</td> 
<?php } ?>

Bei Option 1 wird Option 3 darunter dargestellt, bei Option 2 das selbe. Nur Option 3 wird richtig dargestellt.

Der fehler mus sbei Optionswert 3 liegen, denn wenn ich den Code austausche mit Optionswert2 dann Funktioniert es.

Wo könnte da der Fehler liegen?

LG Fallout
 
Zuletzt bearbeitet:
Da wird wohl irgendwo eine Klammer nicht korrekt geschlossen sein.
Wo genau, ....möchte ich jetzt lieber nicht herausfinden, ...da ist mir der Code zu chaotisch für(könnt fast von mir sein :-) )
 
Hallo, fatalus. Wieso chaotisch *g*, sind doch alle bereiche übersichtlich :o).

Also ich kenn mich leider noch nicht so gut aus, aber in jedem Optionsabeschnitt sind
alle Klammern korrekt geschlossen denk ich.
Option 1:
} 21
{ 21
Option 2:
} 13
{ 13
Option 3:
} 18
{ 18

Könnte dir ja auch die komplette File mal zukommen lassen?

MfG Fallout
 
Hallo,

ich glaube das Problem erkannt zu haben, nur weis ich nicht wie ich es abändern kann.

Und zwar gebe ich das Listing für Style1 über ein Echo aus.

Wie kann ich nun dem Echo sagen, das sich das nur auf die Variable

} elseif (PRODUCT_LISTING_DISPLAY_STYLE == 'style1') {

bezieht?

echo(" ..........

Denn zur zeit gibt er das Echo bei allen 3 Styles (Optionen) aus.


LG Fallout
 
Zurück