Support » Plugin: WP Supersized » Change Slides-Array on Click

  • Hello guys,

    I´m stuck in my code, maybe anyone has a hint for me?

    You can specify Slides for example on every page/post etc. by using NextGen-Galleries (that´s what I use).
    I have a page template which displays posts of a specific category in a special way
    Please take a look at this!

    Now what I want to achieve is that the Supersized-Slides source changes when an image is clicked.

    By using Advanced Custom Fields a gallery-path variable is defined for every post on this side. The path variable is called inside the page template inside a post-loop like:

    $chosenGalPath = get_custom_field_value("galerie-pfad");
    print getAllImagesInDirectory($slideDirectory);

    and the Slides-Array is generated correctly f.e. like this:

    		{image : '', title : ' ', thumb : '', url : ''},
    		{image : '', title : ' ', thumb : '', url : ''},
    		{image : '', title : ' ', thumb : '', url : ''}

    Now how can I get this php output inside my jQuery function as a variable that can be pushed in an array in combination with the post-ID?
    (the code and trial above is not on the given link

    only locally)

    In short way:
    – custom slides-arrays(PHP variable) are dynamically build when page is called (works)
    – how to get these variables back to jquery

    Please excuse if my description sounds confusing..that´s what I am right now 😉
    Any help would be appreciated! Thanks!

Viewing 1 replies (of 1 total)
  • Okay, I´ve managed to have access to the php-generated array for the Supersized slides.
    Inside my jQuery-script the array is type of string. This has to be converted.

    But please take a look at this function:

    function changeSupersizedSlides(postID){
    	var new_slides = jQuery(".slides_"+postID).html();
    		var type = typeof(new_slides);
    	console.log("changeSupersizedSlides var new_slides type of = "+type);
    	//var subarray = new_slides.replace("[","").replace("]","");
    	var myArray = [];
    	var parsedJson = jQuery.parseJSON(new_slides);
    	    image: parsedJson.image,
    	    title: parsedJson.title,
    	    thumb: parsedJson.thumb,
    	    url: parsedJson.url
    	console.log("changeSupersizedSlides myArray[2] = "+myArray[2].image);

    But the code breaks at:
    var parsedJson = jQuery.parseJSON(subarray);
    with this error:
    SyntaxError: JSON Parse error: Expected '}'

    What´s wrong here?

Viewing 1 replies (of 1 total)
  • The topic ‘Change Slides-Array on Click’ is closed to new replies.