How do I display more than one result in a list?

I really need some help with this please. I’m trying to display a list of products rather than just one. This is what I’m using to display a group of products. But at the moment it shows one main product then a smaller list of the rest.

<?php product_display( $collection[$dynaload]['products'],"More Products:",1 ) ?>

If I change it to <?php product_display( $collection[$dynaload]['products'],"More Products:",,0,0,0,1 ) ?> then it shows the remain products in a vertical list

Ideally I’d like to be able to display all of the products (or if not then choose how many to display) but I don’t know the code well enough to know how to change that.

This is the product_display function:

function product_display() {
    # load arguments
    if( func_num_args()==2 ) {
      $products_list=func_get_arg(0); $title=func_get_arg(1); $featured=0; $sortable=0; $showall=0; $cols=5;
    } elseif( func_num_args()==3 ) {
      $products_list=func_get_arg(0); $title=func_get_arg(1); $featured=func_get_arg(2); $sortable=0; $showall=0; $cols=5;
    } elseif( func_num_args()==4 ) {
      $products_list=func_get_arg(0); $title=func_get_arg(1); $featured=func_get_arg(2); $sortable=func_get_arg(3); $showall=0; $cols=5;
    } elseif( func_num_args()==5 ) {
      $products_list=func_get_arg(0); $title=func_get_arg(1); $featured=func_get_arg(2); $sortable=func_get_arg(3); $showall=func_get_arg(4); $cols=5;
    } elseif( func_num_args()==6 ) {
      $products_list=func_get_arg(0); $title=func_get_arg(1); $featured=func_get_arg(2); $sortable=func_get_arg(3); $showall=func_get_arg(4); $cols=func_get_arg(5);
    }

    # initialise
    $row=1;
    $ctr=1;

    # remove old products
    if( is_array( $products_list ) ) {
      foreach( $products_list as $key=>$value ) {
        if( $GLOBALS['products_complete'][$key]['level']==4 ) {
          unset( $products_list[$key] );
        }
      }
    }

    # check and set featured
    if( $GLOBALS['bit1']=="popular" ) { $featured=0; }
    if( $featured ) {
      $found=0;
      foreach( $products_list as $key=>$value ) {
        if( !$found ) {
          $boxed=$key;
          $boxedr=$GLOBALS['products_complete'][$boxed]['id'];
          unset( $products_list[$key] );
          $found=1;
        }
      }

      # get bullets
      usedb( $GLOBALS['country_modules'][$GLOBALS['ccode2']]['db_web'],"dbLinkInt" );
      $query="select * from product_bullets3 where product_id=".$boxedr." and country like \"%".$GLOBALS['ccode2']."%\" order by pos";
      $product_bullets=dbselect( $query,"dbLinkInt" );

      # set first bullet as short title if it is empty
      if( empty( $GLOBALS['products_complete'][$boxed]['short_title'] ) && !empty( $product_bullets[0]['text'] ) ) {
        $GLOBALS['products_complete'][$boxed]['short_title']=$product_bullets[0]['text'];
        unset( $product_bullets[0] );
      }

      # get symbols
      $query="select name,image from product_symbols,product_symbols_map where symbol_id=product_symbols.id and visible=1 and product_id=".$boxedr." order by name";
      $product_symbols=dbselect( $query,"dbLinkInt" );

      # featured image
      if( is_file( $GLOBALS['install_dir']."/images/dynamic/".$GLOBALS['products_complete'][$boxed]['graphics'][10]['filename_image'] ) ) { $img="/images/dynamic/".$GLOBALS['products_complete'][$boxed]['graphics'][10]['filename_image']; } else { $img="/images/site/missing1.jpg"; }



      # featured box title
     # echo '<div class="box-head"><span>Best-seller</span></div>';

      # featured main box
      echo '<div style="margin: 0; padding: 0;">';
      echo ' details here';
      echo '</div>';

      echo '<script type="text/javascript">';
      echo '  $(".sym").hover( function(){';
      echo '    var id=$(this).attr("id").replace( "sym-","ttip-" );';
      echo '    $("#"+id).show();';
      echo '  },function(){';
      echo '    $(".ttip").hide();';
      echo '  });';
      echo '</script>';
    }

      echo $GLOBALS['html_clear'];

    # sorting
    if( $sortable ) {
      if( $sortable=="alpha_down" ) {
        if( is_array( $products_list ) ) {
          $products_list=array_reverse( $products_list,true );
        }
      } elseif( $sortable=="rate_good" ) {
        if( is_array( $products_list ) ) {
          foreach( $products_list as $key=>$value ) { $temp[$key]=$GLOBALS['products_complete'][$key]['rating_cnt']+$GLOBALS['products_complete'][$key]['rating_offset']; }
          asort( $temp ); $products_list=$temp; unset( $temp );
        }
      } elseif( $sortable=="rate_bad" ) {
        if( is_array( $products_list ) ) {
          foreach( $products_list as $key=>$value ) { $temp[$key]=$GLOBALS['products_complete'][$key]['rating_cnt']+$GLOBALS['products_complete'][$key]['rating_offset']; }
          asort( $temp ); $products_list=$temp; unset( $temp ); $products_list=array_reverse( $products_list,true );
        }
      } elseif( $sortable=="price_high" ) {
        if( is_array( $products_list ) ) {
          foreach( $products_list as $key=>$value ) { $temp[$key]=$GLOBALS['products_complete'][$key]['price1']; }
          asort( $temp ); $products_list=$temp; unset( $temp );
        }
      } elseif( $sortable=="price_low" ) {
        if( is_array( $products_list ) ) {
          foreach( $products_list as $key=>$value ) { $temp[$key]=$GLOBALS['products_complete'][$key]['price1']; }
          asort( $temp ); $products_list=$temp; unset( $temp ); $products_list=array_reverse( $products_list,true );
        }
      }
    }


    # calculate last row
    $prods=0;
    if( is_array( $products_list ) ) {
      foreach( $products_list as $key=>$value ) { if( !isset( $GLOBALS['products_complete'][$key]['nodisplay'] ) || $showall==1 ) { $prods++; } }
      $lastrow=ceil( $prods/$cols );
    }

    if( is_array( $products_list ) ) {
      echo '<div class="products"'; if( $cols==1 ) { echo ' style="padding: 0 12px;"'; } echo '>';
      foreach( $products_list as $key=>$value ) { if( !isset( $GLOBALS['products_complete'][$key]['nodisplay'] ) || $showall==1 ) {
        # start line box
        if( $ctr==1 ) { echo '<div class="productlist-line"'; if( $row==$lastrow ) { echo ' style="border: 0; margin: 0; padding: 0;"'; } echo '>'; }

        # product float
        echo '<div class="rest'; if( $ctr==$cols ) { echo " productlist-last"; } echo'">';
	echo 'text here';
        echo '</div>';
        $ctr++;
        if( $ctr>$cols ) { $ctr=1; $row++; }

        # end line box
        if( $ctr==1 ) { echo $GLOBALS['html_clear'].'</div>'; }
      } }
      if( $ctr!=1 ) { echo $GLOBALS['html_clear'].'</div>'; }
      echo '</div>';
    }
  }

Hi,

The code is kinda difficult to read through, but at a glance, perhaps if you try this:

<?php product_display( $collection[$dynaload]['products'],"More Products:" ) ?>

does that give you the output you want?

Where does this code come from anyway, is it an ecommerce application? It seems to be a little, ah… outdated, to say the least!

Unfortunately I tried that and it stops displaying the main product but instead of then showing all of the products in that format it then shows the list of them all :frowning:

You’re right though it is ecommerce but I agree it is out of date!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.