Hello Sonja,
thank you very much for this detailed explanation.
I had problems to load the home.json.php because this I realised it with a plugin and a routing.
If someone have also problems here are my code:
config.php:
c::set('routes', array(
array(
'pattern' => 'api/tagfilter',
'method' => 'POST',
'action' => function() {
$data = tagfilter(kirby()->request()->data());
return response::json($data);
}
))
));
inside the pluginfolder I created a folder with name: tagfilter an da php file with name tagfilter.php with this code:
<?php
function tagfilter($data){
$page = page('projekte')->children()->visible();
$param = kirby()->request()->data()['param'];
if(empty($param)){
$projects = $page; //fro reseting the Tag filter
}
else {
$projects = $page->filterBy('achievements', $param);
}
return snippet('slideshow', array('projects' => $projects), true);
}
And the javascript:
// var archivement = $(this).attr('href');
var archivement = $(this).data('filter'); // get the value to filter by from a data-filter attribute
var url = 'api/tagfilter'; ///window.location.href + 'home.json.php'; // here we call the JSON representation (should be the home page url + .json
$.ajax({
type: 'POST',
url: 'api/tagfilter',
data: {param: archivement},
dataType: 'html',
beforeSend: function() {
console.log('beforeSend: ' + JSON.stringify({param: archivement}));
$('#spinnerContainer').toggleClass('fadeout fadein');
},
success: function(response) {
console.log('Success: ' + JSON.stringify(response));
$('#slideshowContainer').fadeOut('slow', function(){
$('#slideshowContainer').children().remove;
$('#slideshowContainer').html(response).promise().then(function(){
$('#textSlidshow').cycle({
speed: 600,
manualSpeed: 100,
timeout: 0,
next: '#next',
prev: '#prev',
fx: 'fade',
slides: '> article',
caption: '#slide-caption',
// captionTemplate: '{{slideNum}} / {{slideCount}}'
});
$('#imageSlideshow').cycle({
speed: 600,
manualSpeed: 100,
timeout: 0,
next: '#next',
prev: '#prev',
fx: 'fade',
slides: '> .nested-slideshow'
});
$('.inner-slideshow').cycle({
timeout: 0,
fx: 'fade',
prev: '.prevSubSlide',
next: '.nextSubSlide'
});
$('#slideshowContainer').fadeIn('slow');
});
});
},
error: function(response) {
console.log('Error: ' + JSON.stringify(response));
},
complete: function() {
$('#spinnerContainer').toggleClass('fadein fadeout');
$('#slideshow-container').fadeIn('slow');
}
});
Cheers