• Hi again,

    I’d like to create some type of slider-widget. I know, there are plenty out there, but it seems none of them really is that convenient to use.

    So I wanted to do create my own with the option of repeatable fields and a media uploader.
    After some time working I’ve come so one media uploader button and a multiple select field catching the images.

    <select multiple="multiple" name="<?php echo $this->get_field_name( 'sosuImages' ); ?>[]" id="<?php echo $this->get_field_id( 'sosuImages' ); ?>" style="width:100%;"></select>

    Saving goes like this:

    $instance['sosuImages'] = array();
    foreach ($new_instance['sosuImages'] as $img) {
    			$instance['sosuImages'][] = $img;
    		}

    With jQuery I’ll get all option fields selected when the saving button is clicked, getting an array with all the option values.

    Works gread using it in the theme widgets section, but breaks with ur plugin.
    Do you have any ideas why?

    (this is the js btw)

    jQuery(document).on('click', "#sosuNivoUpload", function (){
    
    		tb_show('', 'media-upload.php?type=image&TB_iframe=true');
    		$('#TB_window').css('z-index', 1005);
    		widget_content = jQuery(this).parent();
    
    		window.send_to_editor = function(html) {
    
    			imgurl = jQuery('img',html).attr('src');
    			imgalt = (jQuery('img',html).attr('alt') != '') ? jQuery('img',html).attr('alt') : jQuery('img',html).attr('src');
    
    			var current = $("textarea[id*='sosunivowidget']").val();
    
    			$("select[id*='sosunivowidget']").append($('<option></option>').val(imgurl).html(imgalt));
    			$("textarea[id*='sosunivowidget']").val(current + imgurl + "\n");
    
    			tb_remove();
    			return false;
    		};
    
    	});

    Cheers,
    Michael

    https://www.ads-software.com/extend/plugins/siteorigin-panels/

Viewing 6 replies - 1 through 6 (of 6 total)
  • I am having a similar issue, I suppose.

    Have you attempted to print_r( $instance )? Even though my field values save, the $instance array is always set to default. I am pretty sure Page Builder uses it’s own mechanism for saving widget instance data. This is also a problem for me as I have several instances of the widget. Each time I edit the page, I must reset all of the instances.

    Did you get anywhere with this? I am also having the same issue where my widget works fine in the theme but not in the page builder!

    Thread Starter Michael

    (@ms-s)

    Sadly, no.
    I moved away from this plugin over to https://www.ads-software.com/plugins/page-layout-builder/

    But mostly because of the bootstrap compatibily. So I didnt really looked for an answer to this topic anymore

    That’s a real shame. Is that plugin better would you say?

    Thread Starter Michael

    (@ms-s)

    not having too much trouble with it yet. As said, I like the bootstrap part of it, but I think its still bootstrap 2.x.

    The first page builder plugin which uses bootstrap 3 gets my heart!

    It won’t let me disable the bootstrap CSS now I have selected it and it’s messing up my site :l

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘saving array fails’ is closed to new replies.