Support

Account

Forum Replies Created

  • for your block template, after you’ve registered the block with “editor”=>”attributes”=>”cover” = ‘…’

    <?php if (is_admin() && @$block['example']['attributes']['cover']): ?>
    <div style="background:url(<?= $block['example']['attributes']['cover'] ?>) no-repeat center #eee; background-size:contain;width:500px;height:600px;"></div>
    <?php else: ?>
    <!-- your block html -->
    <?php endif; ?>

    EDIT: eh – spoke too soon. This will change the block in the editor not just preview. Is there a conditional to determine if the block is being “previewed”?

  • I am thinking of exactly this – might end up writing one for our internal workflow. Unless anything has come about since May 2014?

  • Could be related to this issue, which I had created a patch for 5.1.7.1
    http://support.advancedcustomfields.com/forums/topic/unnecessary-ajax-calls/

  • I’ve come up with a rudimentary patch to input.js that solves the excessive $.each() and $el.closest() calls when there is an excessive amount of repeatables.

    changing this:

    		get_visibility : function( $target, rule ){
    			
    			//console.log( 'conditional_logic.get_visibility(%o, %o)', $target, rule );
    			
    			// update cache (cache is cleared after render_fields)
    			if( !acf.isset(this.cache, rule.field) ) {
    				
    				//console.log('get_fields(%o)', rule.field);
    				
    				// get all fields for this field_key and store in cache
    				this.cache[ rule.field ] = acf.get_fields(rule.field, false, true);
    				
    			}
    			
    			
    			// vars
    			var $triggers = this.cache[ rule.field ],
    				$trigger = null;
    			
    			
    			// bail early if no triggers found
    			if( !$triggers.exists() ) {
    				
    				return false;
    				
    			}
    			
    			
    			// set $trigger
    			$trigger = $triggers.first();
    			
    			
    			// find better $trigger
    			if( $triggers.length > 1 ) {
    				
    				$triggers.each(function(){
    					
    					// vars
    					$parent = $(this).parent();
    					
    					
    					if( $target.closest( $parent ).exists() ) {
    						
    						$trigger = $(this);
    						return false;
    					}
    
    				});
    				
    			}
    			
    			
    			// calculate
    			var visibility = this.calculate( rule, $trigger, $target );
    			
    			
    			// return
    			return visibility;
    		},

    To this:

    		get_visibility : function( $target, rule ){
    			
    			//console.log( 'conditional_logic.get_visibility(%o, %o)', $target, rule );
    			
    			// update cache (cache is cleared after render_fields)
    			if( !acf.isset(this.cache, rule.field) ) {
    				
    				//console.log('get_fields(%o)', rule.field);
    				
    				// get all fields for this field_key and store in cache
    				this.cache[ rule.field ] = acf.get_fields(rule.field, false, true);
    				
    			}
    			
    			
    			// vars
    			var $triggers = this.cache[ rule.field ],
    /*change*/		$trigger  = $target.closest('.acf-row').find('tr.field_key-'+rule.field);
    			
    			
    			// bail early if no triggers found
    			if( !$triggers.exists() ) {
    				
    				return false;
    				
    			}
    /*change*/	else if ( !$trigger.exists() ) {			
    			
    				// set $trigger
    				$trigger = $triggers.first();
    				
    				
    				// find better $trigger
    				if( $triggers.length > 1 ) {
    					
    					$triggers.each(function(){
    						
    						// vars
    						$parent = $(this).parent();
    						
    						
    						if( $target.closest( $parent ).exists() ) {
    							
    							$trigger = $(this);
    							return false;
    						}
    
    					});
    					
    				}
    
    			}
    			
    			
    			// calculate
    			var visibility = this.calculate( rule, $trigger, $target );
    			
    			
    			// return
    			return visibility;
    		}
  • Semi-related – I’ve got a page with a repeatable field that the client has created ~150 repeated fields with.

    On some browsers this causes the page to become unresponsive. I say semi-related because it looks to be due to the get_visibility() js method for fields with conditional logic.

    Attached is the js profile. If I remove all field conditional rules, or force get_visibility() to return true, then the page does not become unresponsive.

Viewing 5 posts - 1 through 5 (of 5 total)