-
Notifications
You must be signed in to change notification settings - Fork 1
/
search.php
152 lines (132 loc) · 4.8 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/**
* The template for displaying the search page.
*
* @package WordPress
* @subpackage FAU
* @since FAU 1.0
*/
get_header();
$notfound = false;
?>
<div id="content">
<div class="content-container">
<div class="content-row">
<div class="searchpage-content ">
<main>
<h1 id="maintop" class="screen-reader-text"><?php echo __('Webauftritt durchsuchen','fau'); ?></h1>
<?php
if(strlen(get_search_query()) > 0) {
// Suchbegriff vorhanden
if(have_posts()) {
// Treffer vorhanden
global $wp_query, $wp_rewrite;?>
<h2><?php _e('Suchergebnisse','fau'); ?></h2>
<?php
get_template_part('template-parts/search', 'form');
$notice_search = get_theme_mod('search_notice_searchregion');
if (!fau_empty($notice_search)) { ?>
<p class="notice-hinweis"><?php echo $notice_search; ?></p>
<?php } ?>
<p class="meta-resultinfo"><?php
if ($wp_query->found_posts>1) {
echo __("Es wurden",'fau');
} else {
echo __("Es wurde",'fau');
}
echo " ".$wp_query->found_posts.' '.__("Treffer gefunden",'fau').":"; ?>
</p>
<?php
$listtypes = get_theme_mod('search_post_types');
echo '<ul class="searchresults">';
while ( have_posts() ) {
the_post();
echo fau_display_search_resultitem();
}
echo "</ul>";
if ( $wp_query->max_num_pages > 1 ) {
if (absint( get_query_var( 'paged' ))>0) {
$paged = absint( get_query_var( 'paged' ));
} else {
$paged =1;
}
$pagenum_link = html_entity_decode( get_pagenum_link() );
$query_args = array();
$url_parts = explode( '?', $pagenum_link );
if ( isset( $url_parts[1] ) ) {
wp_parse_str( $url_parts[1], $query_args );
}
$pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
$pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
$format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
$links = paginate_links( array(
'base' => $pagenum_link,
'format' => $format,
'total' => $wp_query->max_num_pages,
'current' => $paged,
'mid_size' => 1,
'prev_text' => '<span class="meta-nav">←</span> '.__( 'Zurück', 'fau' ),
'next_text' => __( 'Weiter', 'fau' ).' <span class="meta-nav">→</span>',
'before_page_number' => '<span class="screen-reader-text">'.__( 'Seite', 'fau' ).' </span>'
) );
?>
<?php if ( $links ) { ?>
<nav id="nav-pages" class="navigation paging-navigation" role="navigation" aria-label="<?php _e( 'Weitere Suchergebnisse', 'fau' ); ?>">
<div class="nav-links">
<?php echo $links; ?>
</div>
</nav>
<?php }
}
} else {
// keine Treffer
$notfound = true;
?>
<div class="error-notice">
<p class="hinweis">
<strong><?php _e('Nichts gefunden.','fau'); ?></strong>
</p>
<p>
<?php _e('Leider konnte für Ihren Suchbegriff kein passendes Ergebnis gefunden werden.','fau'); ?>
</p>
</div>
<?php
get_template_part('template-parts/search', 'form');
}
} else {
// bisher kein SUchbegriff eingegeben
?>
<div class="error-notice">
<p class="hinweis">
<strong><?php _e('Kein Suchbegriff.','fau'); ?></strong>
</p>
<p>
<?php _e('Bitte geben Sie einen Suchbegriff in das Suchfeld ein.','fau'); ?>
</p>
</div>
<?php
get_template_part('template-parts/search', 'form');
}
?>
<?php
get_template_part('template-parts/search', 'helper');
?>
</main>
</div>
<?php if ( (is_plugin_active( 'FAU-Fehlermeldungen/fau-fehlermeldungen.php' ) && ($notfound)) || (is_active_sidebar( 'search-sidebar' )) ) { ?>
<aside class="portalpage-sidebar" aria-label="<?php echo __('Sidebar','fau');?>">
<?php
if ( is_plugin_active( 'FAU-Fehlermeldungen/fau-fehlermeldungen.php' ) && ($notfound)) {
echo do_shortcode('[fau_fehlermeldungen type="404" fulltext="false" ]');
}
if ( is_active_sidebar( 'search-sidebar' ) ) {
dynamic_sidebar( 'search-sidebar' );
} ?>
</aside>
<?php } ?>
</div>
</div>
</div>
<?php
get_footer();