category bestand alpha filter
This commit is contained in:
parent
52cdae478b
commit
240f244e2b
2 changed files with 49 additions and 36 deletions
|
|
@ -3,27 +3,21 @@
|
||||||
Template Name: Bestand
|
Template Name: Bestand
|
||||||
*/
|
*/
|
||||||
|
|
||||||
get_header();
|
get_header();
|
||||||
|
|
||||||
|
|
||||||
$numberofusers = $wpdb->get_results( "
|
|
||||||
SELECT post_title
|
|
||||||
FROM {$wpdb->posts}
|
|
||||||
WHERE post_type = 'post' and post_status = 'publish'
|
|
||||||
ORDER BY post_title ASC" );
|
|
||||||
//echo '<pre>'; print_r($numberofusers); echo '</pre>';
|
|
||||||
|
|
||||||
|
$categories = get_the_category();
|
||||||
$args = array(
|
$args = array(
|
||||||
'cat' => $categories[0]->cat_ID,
|
'cat' => $categories[0]->cat_ID,
|
||||||
'orderby' => 'title',
|
'orderby' => 'title',
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
|
'nopaging' => true,
|
||||||
);
|
);
|
||||||
$query = new WP_Query( $args );
|
$query = new WP_Query( $args );
|
||||||
$available_chars = [];
|
$available_chars = [];
|
||||||
if ( $query->have_posts() ) {
|
if ( $query->have_posts() ) {
|
||||||
while ( $query->have_posts() ) :
|
while ( $query->have_posts() ) :
|
||||||
$query->the_post();
|
$query->the_post();
|
||||||
array_push($available_chars, substr(get_the_title(),0,1));
|
array_push($available_chars, mb_substr(get_the_title(),0,1,"utf-8"));
|
||||||
endwhile;
|
endwhile;
|
||||||
wp_reset_postdata();
|
wp_reset_postdata();
|
||||||
};
|
};
|
||||||
|
|
@ -35,10 +29,11 @@ get_header();
|
||||||
<section class="background-color-white category">
|
<section class="background-color-white category">
|
||||||
<div class="content-wrap">
|
<div class="content-wrap">
|
||||||
<h2>
|
<h2>
|
||||||
<?php $categories = get_the_category();
|
<?php
|
||||||
if ( ! empty( $categories ) ) {
|
if ( ! empty( $categories ) ) {
|
||||||
echo esc_html( $categories[0]->name );
|
echo esc_html( $categories[0]->name );
|
||||||
} ?>
|
}
|
||||||
|
?>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -66,28 +61,28 @@ get_header();
|
||||||
<div id="c139" class="frame frame-default frame-type-list frame-layout-0">
|
<div id="c139" class="frame frame-default frame-type-list frame-layout-0">
|
||||||
<div class="tx-indexedsearch">
|
<div class="tx-indexedsearch">
|
||||||
<div class="tx-indexedsearch-searchbox">
|
<div class="tx-indexedsearch-searchbox">
|
||||||
<form method="get" role="search" action="<?php echo site_url(‘/’); ?>">
|
<fieldset>
|
||||||
<fieldset>
|
<div class="tx-indexedsearch-form">
|
||||||
<div class="tx-indexedsearch-form">
|
<label for="tx-indexedsearch-searchbox-sword">
|
||||||
<label for="tx-indexedsearch-searchbox-sword"><?php _e('Ergebnisse filtern', 'kit'); ?>:</label>
|
<?php _e('Ergebnisse filtern', 'kit'); ?>:
|
||||||
<div>
|
</label>
|
||||||
<ul class="catFilter">
|
<div>
|
||||||
<li class='available active'><a href=#>Alle</a></li>
|
<ul class="catFilter">
|
||||||
<?php
|
<li class='available active'><a href=#>Alle</a></li>
|
||||||
$chars = array("0-9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Ä", "Ü", "Ö", "ß");
|
<?php
|
||||||
foreach($chars as $item) {
|
$chars = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Ä", "Ü", "Ö");
|
||||||
if (in_array($item, $available_chars)) {
|
foreach($chars as $item) {
|
||||||
echo "<li class='available'><a href=#>".$item."</a></li>";
|
if (in_array($item, $available_chars)) {
|
||||||
} else {
|
echo "<li class='available'><a href=#>".$item."</a></li>";
|
||||||
echo "<li>".$item."</li>";
|
} else {
|
||||||
};
|
echo "<li>".$item."</li>";
|
||||||
};
|
};
|
||||||
?>
|
};
|
||||||
</ul>
|
?>
|
||||||
</div>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</div>
|
||||||
</form>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -109,7 +104,7 @@ get_header();
|
||||||
while ( $query->have_posts() ) :
|
while ( $query->have_posts() ) :
|
||||||
|
|
||||||
$query->the_post();
|
$query->the_post();
|
||||||
$first_char = substr( esc_html( get_the_title() ) ,0,1 );
|
$first_char = mb_substr( esc_html( get_the_title() ) ,0,1,"utf-8" );
|
||||||
|
|
||||||
if ($last_first_char === $first_char) {
|
if ($last_first_char === $first_char) {
|
||||||
echo '<li>
|
echo '<li>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,24 @@
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
$("ul.catFilter li.available").on("click", function(e){
|
$("ul.catFilter li.available").on("click", function(e){
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("test");
|
|
||||||
|
var catFilter = document.getElementsByClassName("catFilter")[0];
|
||||||
|
var catElement = catFilter.querySelector('.active');
|
||||||
|
catElement.classList.remove('active');
|
||||||
|
this.classList.add('active');
|
||||||
|
|
||||||
|
|
||||||
|
var requestLetter = $(this).find('a:first').text().trim();
|
||||||
|
var lists = document.getElementsByClassName("bestandliste");
|
||||||
|
for (let list of lists) {
|
||||||
|
var listLetter = list.id;
|
||||||
|
if (listLetter != requestLetter && requestLetter != "Alle") {
|
||||||
|
list.style.display = "none";
|
||||||
|
} else {
|
||||||
|
list.style.display = "block";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue