template_dir = "/"; $template->left_delimiter = "<#"; $template->right_delimiter = "#>"; // Variables navegador if( (isset( $_REQUEST['idx'] ) ) && (is_numeric( $_REQUEST['idx'] ) ) ) { $idx = $_REQUEST['idx']; } else { $idx = 1; } if( isset( $site->config['max_results_per_page'] ) ) $max_results = $site->config['max_results_per_page']; else $max_results = 5; // ------------------- // Obtención de registros totales // ---- $site->AddActionParameter( "table", "ofertas_destacadas" ); $site->AddActionParameter( "expression", "COUNT(*)" ); $site->AddActionParameter( "additional", "WHERE visible=1" ); if( $row = $site->ExecuteAction( SELECT_FROM_TABLE ) ) { $total_registros = $row[0][0]; $total_paginas = floor ( $total_registros / $max_results ); if ( fmod ( $total_registros, $max_results ) > 0 ) $total_paginas++; } else { $site->showLastError( "index.php" ); exit; } if( $total_registros > 0 ) { $rId = array(); $rTitulo = array(); $rDescripcion = array(); $rVisible = array(); $muestra_listado = 1; $site->AddActionParameter( "table", "ofertas_destacadas" ); $site->AddActionParameter( "expression", "*" ); $site->AddActionParameter( "additional", sprintf( "WHERE visible=1 LIMIT %s, %s", ($idx-1) * $max_results, $max_results ) ); $site->AddActionParameter( "result_type", MYSQL_ASSOC ); if( $row = $site->ExecuteAction( SELECT_FROM_TABLE ) ) { foreach ( $row as $r ) { $rId[] = $r['id']; $rFoto[] = $r['ruta_foto']; $rTitulo[] = $r['titulo']; $rDescripcion[] = $r['descripcion']; $rVisible[] = $r['visible']; } } else { $site->showLastError( "index.php" ); exit; } } else $muestra_listado = 0; $template->assign ( "webroot_path", $site->config['webroot_path'] ); $template->assign ( "idx", $idx ); $template->assign ( "muestra_listado", $muestra_listado); $template->assign ( "max_results", $max_results); $template->assign ( "total_registros", $total_registros); $template->assign ( "total_paginas", $total_paginas); $template->assign ( "rId", $rId); $template->assign ( "rFoto", $rFoto); $template->assign ( "rTitulo", $rTitulo); $template->assign ( "rDescripcion", $rDescripcion); $template->assign ( "rVisible", $rVisible); $template->display( "index.tpl" ); ?>