//print '
'; print_r($_GET); print ''; $keyword = $vlaks = $traininglevel = $trainingtype = $vakgebied; $keyword = ($_GET['opt']['keywords'] != '') ? $_GET['opt']['keywords'] : ""; $vlaks = ($_GET['opt']['9vlaks'] != '') ? $_GET['opt']['9vlaks'] : ""; $traininglevel = ($_GET['opt']['traininglevel'] != '') ? $_GET['opt']['traininglevel'] : ""; $trainingtype = ($_GET['opt']['trainingtype'] != '') ? $_GET['opt']['trainingtype'] : ""; $vakgebied = ($_GET['opt']['vakgebied'] != '') ? $_GET['opt']['vakgebied'] : ""; $sort = $_GET['opt']['sort']; $sort_parts = explode('-', $sort); $page = ($_GET['page'] == '') ? 0 : $_GET['page']; $page_size = 10; $page_offset = $page * $page_size; $sql = "SELECT node.title AS title, node.nid AS nid,"; $sql .= ($sort_parts[0] == 'traininglevel') ? " field_data_field_traininglevel_options.field_traininglevel_options_value AS traininglevel," : ""; $sql .= ($sort_parts[0] == 'trainingtype') ? " field_data_field_trainingtype_options.field_trainingtype_options_value AS trainingtype," : ""; $sql .= ($sort_parts[0] == 'vakgebied') ? " field_data_field_vakgebied_options.field_vakgebied_options_value AS vakgebied," : ""; $sql .= ($sort_parts[0] == 'dayscount') ? " field_data_field_aantaldagen.field_aantaldagen_value AS dayscount," : ""; $sql .= " 'node' AS field_data_body_node_entity_type FROM node"; $sql .= ($vlaks != '') ? " LEFT JOIN field_data_field_9vlaks_options field_data_field_9vlaks_options ON node.nid = field_data_field_9vlaks_options.entity_id AND (field_data_field_9vlaks_options.entity_type = 'node' AND field_data_field_9vlaks_options.deleted = 0)" : ""; $sql .= ($traininglevel != '' OR $sort_parts[0] == 'traininglevel') ? " LEFT JOIN field_data_field_traininglevel_options field_data_field_traininglevel_options ON node.nid = field_data_field_traininglevel_options.entity_id AND (field_data_field_traininglevel_options.entity_type = 'node' AND field_data_field_traininglevel_options.deleted = 0)" : ""; $sql .= ($trainingtype != '' OR $sort_parts[0] == 'trainingtype') ? " LEFT JOIN field_data_field_trainingtype_options field_data_field_trainingtype_options ON node.nid = field_data_field_trainingtype_options.entity_id AND (field_data_field_trainingtype_options.entity_type = 'node' AND field_data_field_trainingtype_options.deleted = 0)" : ""; $sql .= ($vakgebied != '' OR $sort_parts[0] == 'vakgebied') ? " LEFT JOIN field_data_field_vakgebied_options field_data_field_vakgebied_options ON node.nid = field_data_field_vakgebied_options.entity_id AND (field_data_field_vakgebied_options.entity_type = 'node' AND field_data_field_vakgebied_options.deleted = 0)" : ""; $sql .= ($sort_parts[0] == 'dayscount') ? " LEFT JOIN field_data_field_aantaldagen field_data_field_aantaldagen ON node.nid = field_data_field_aantaldagen.entity_id AND (field_data_field_aantaldagen.entity_type = 'node' AND field_data_field_aantaldagen.deleted = 0)" : ""; // keywords field join to search through it $sql .= ($keyword != '') ? " LEFT JOIN field_data_field_keywords field_data_field_keywords ON node.nid = field_data_field_keywords.entity_id AND (field_data_field_keywords.entity_type = 'node' AND field_data_field_keywords.deleted = 0)" : ""; $sql .= ($keyword != '') ? " LEFT JOIN field_data_body field_data_body ON node.nid = field_data_body.entity_id AND (field_data_body.entity_type = 'node' AND field_data_body.deleted = 0)" : ""; $sql .= " WHERE ( (node.status = 1)"; $sql .= " AND (node.type = 'training')"; $sql .= ($vlaks != '') ? " AND (field_data_field_9vlaks_options.field_9vlaks_options_value IN ('".$vlaks."'))": ""; $sql .= ($traininglevel != '') ? " AND (field_data_field_traininglevel_options.field_traininglevel_options_value IN ('".$traininglevel."'))": ""; $sql .= ($trainingtype != '') ? " AND (field_data_field_trainingtype_options.field_trainingtype_options_value IN ('".$trainingtype."'))": ""; $sql .= ($vakgebied != '') ? " AND (field_data_field_vakgebied_options.field_vakgebied_options_value IN ('".$vakgebied."'))": ""; $sql .= ($keyword != '') ? " AND (node.title LIKE '%".$keyword."%' OR field_data_field_keywords.field_keywords_value LIKE '%".$keyword."%' OR field_data_body.body_value LIKE '%".$keyword."%')" : ""; $sql .= " ) GROUP BY title"; $sql .= ($sort != '') ? " ORDER BY ".$sort_parts[0]." ".strtoupper($sort_parts[1]) : " ORDER BY node_title ASC"; $limit .= ($page != '') ? " LIMIT ".($page*$page_size).",".$page_size : " LIMIT 0,".$page_size; //print '
'; print_r($sql.$limit); print ''; //exit(); $result = db_query($sql); $total = $result->rowCount(); $result = db_query($sql.$limit); $title = ($total > 1 ) ? $total." opleidingen gevonden" : "1 opleiding gevonden"; $title = ($total == 0 ) ? "Geen opleidingen gevonden" : $title; $add_querystring = array(); if($_GET['opt']['sort'] != '') { $add_querystring[] = 'opt[sort]='.$_GET['opt']['sort']; } if($_GET['opt']['keywords'] != '') { $add_querystring[] = 'opt[keywords]='.$_GET['opt']['keywords']; } if($_GET['opt']['9vlaks'] != '') { $add_querystring[] = 'opt[9vlaks]='.$_GET['opt']['9vlaks']; } if($_GET['opt']['traininglevel'] != '') { $add_querystring[] = 'opt[traininglevel]='.$_GET['opt']['traininglevel']; } if($_GET['opt']['trainingtype'] != '') { $add_querystring[] = 'opt[trainingtype]='.$_GET['opt']['trainingtype']; } if($_GET['opt']['vakgebied'] != '') { $add_querystring[] = 'opt[vakgebied]='.$_GET['opt']['vakgebied']; } $add_querystring = '&'.implode('&', $add_querystring); $page_total = ceil($total/$page_size); $pager = ''; if($page_total > 1 ) { $pager .= '
';
$pager .= '
";
}
?>
- ';
$pager .= ($page>0 && $page_total>0) ? '
- « eerste
- < vorige ' : ""; for($i=0; $i < $page_total; $i++) { if($i == $page) { $pager .= '
- '.($i+1).' '; } else { $pager .= '
- '.($i+1).' '; } } $pager .= ($page<$page_total) ? '
- volgende >
- laatste » ' : ''; $pager .= "
Er zijn geen resultaten gevonden.