Domelov 2005-11-24 10:40
Witam. Mam 4 kategorie produktów. Jak zrobić aby randomProduct losował i pokazywał tylko z 3 pierwszych kategorii ??? Z góry dziękuje za pomoc Domelov
2005-11-24 13:13
edytuj plik randomProduct.php i zamien funkcje throwRandomProduct( ) na:
<?php function throwRandomProduct ( $sFile = 'randomProduct.tpl' ){ global $aProduct , $tpl , $oFoto ; /* * tutaj wpisz po kolei id kazdej z tych kategorii * ktorych produkty sie maja wyswietlac */ $aCategories [] = 1 ; $aCategories [] = 2 ; $aCategories [] = 3 ; $aFile = file ( DIR_DB . DB_PRODUCTS ); $iCount = count ( $aFile ); $iLine = rand ( 1 , $iCount - 1 ); $aFoto = throwFirstPhoto ( 1 ); if( !isset( $aFoto ) ) return null ; $bFind = null ; list( $aProduct [ 'position' ], $aProduct [ 'name' ], $aProduct [ 'id' ], $aProduct [ 'category' ], $aProduct [ 'price' ], $aProduct [ 'shortDescription' ], $aProduct [ 'fullDescription' ], $aProduct [ 'status' ] ) = explode ( '$' , $aFile [ $iLine ] ); if( in_array ( $aProduct [ 'category' ], $aCategories ) && $aProduct [ 'status' ] == 1 && isset( $aFoto [ $aProduct [ 'id' ]] ) && is_file ( DIR_PRODUCTS_FILES . $aFoto [ $aProduct [ 'id' ]][ 'foto' ] ) ){ $aName = $oFoto -> throwNameExtOfFile ( $aFoto [ $aProduct [ 'id' ]][ 'foto' ] ); $aProduct [ 'file' ] = $aFoto [ $aProduct [ 'id' ]][ 'foto' ]; $aProduct [ 'fotoSmall' ] = DIR_PRODUCTS_FILES . $aName [ 0 ]. '_m.' . $aName [ 1 ]; $aProduct [ 'fotoBig' ] = DIR_PRODUCTS_FILES . $aFoto [ $aProduct [ 'id' ]][ 'foto' ]; $bFind = true ; } if( isset( $bFind ) ) return $tpl -> tbHtml ( $sFile , 'RANDOM_PRODUCT' ); else return throwRandomProduct ( $sFile ); } // end function throwRandomProduct ?>
neofix 2005-12-15 17:12
Hmm, what does this do? Anyone care for transelating in to English? Seems like it get's random products from specified categories.. Is that correct?
- Neofix 2005-12-15 19:11
neofix - yes it throw random products from specified categories (in array)
witaj.net neofix 2005-12-15 20:30
Managed to find it out myself by trying it, but thanks alot Treewood for replying! :)
- Neofix