WordPress.org

Ready to get started?Download WordPress

Forums

Page Builder by SiteOrigin
saving array fails (7 posts)

  1. Michael
    Member
    Posted 1 year ago #

    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

    http://wordpress.org/extend/plugins/siteorigin-panels/

  2. scottsawyer
    Member
    Posted 8 months ago #

    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.

  3. Tenatious
    Member
    Posted 7 months ago #

    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!

  4. Michael
    Member
    Posted 7 months ago #

    Sadly, no.
    I moved away from this plugin over to http://wordpress.org/plugins/page-layout-builder/

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

  5. Tenatious
    Member
    Posted 7 months ago #

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

  6. Michael
    Member
    Posted 7 months ago #

    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!

  7. Tenatious
    Member
    Posted 7 months ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic