Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi @jonathan, this is what I have:

    <?php if( have_rows('section') ):
    
        while ( have_rows('section') ) : the_row();
    		
    		// Repeater Block
            if ( get_row_layout() == 'content_block_repeater' ):
    			
    			// Repeater Field
    			if( have_rows('repeater') ) :
    			$counter = get_sub_field('repeater');
    			//$counter = get_field('repeater');
    			echo '<div class="repeater_block">';
    				// Loop
    				while ( have_rows('repeater') ) : the_row();
    					$h3 = get_sub_field('repeater_h3');
    					$em = get_sub_field('repeater_em');
    					$count = count( $counter );
    					if ( $count == 3 ) {
    						$span = 'span33';
    					} elseif ( $count == 2 ) {
    						$span = 'span50';
    					} else {
    						$span = 'span100';
    					}
    					// Output
    					echo '<div class="'. $span .'">';
    						echo '<h3>'. $h3 .'</h3>';
    						echo '<em>'. $em .'</em>';
    					echo '</div>';
    					// End Output
    				endwhile;
    				// End Loop
    			echo '</div>';
    			endif;
    		
    		// Text Block
            elseif ( get_row_layout() == 'content_block_text' ): 
            
            	// get_template_part( '/_content/text' );
            
            else :
            	
            	// No Content
     
            endif;
     
        endwhile;
     
    endif; ?>
  • Hi,

    Okay so I’ve taken a look at your page and you have two issues.

    1. You’ve included the script two times. you should only include google maps api once through functions.php using wp_enqueue_script.
    2. In your file acf-maps.js, remove the top <script> line. That’s HTML code and it wont work (and shouldn’t be) in a js file.

    Do these and I think you’ll find it working!

  • Hi,

    Hm okay. Could you try this instead:

    
    var e = jQuery.Event("keypress");
    e.which = 13; //choose the one you want
    e.keyCode = 13;
    $("#theInputToTest").trigger(e);
    

    And to clarify, your address is filled in to the input field correctly? I mean, you see the address added? Are you just filling it with GPS coordinates or an actual address?

  • Hi Jonathan, thanks for the answer.

    I tried the code below, but the trigger doesn’t work (does nothing).

    This is my actual code (useful fragment):

    $(".acf-google-map .no-value input").val(latitude+" "+longitude).focus();
    var e = jQuery.Event("keydown");
    e.which = 13; // # key code value for 'Enter'
    $(".acf-google-map .no-value input").trigger(e);

    The value is not saved when i’m saving the post.

  • Been playing around and so far this is my code that works, it gets the value of the checkbox but only on the selected/saved one. The code below gives me “southern 360” where 360 is the value of the saved/selected checkbox and southern is the correct region if based on the 360 ID. This is the same on all checkbox divs though and what I need is for each checkbox div to show the ID value of its respective checkbox.

    How can I change it so that it will add the value of the checkbox per checkbox and not the selected one?

    function filter_region_taxonomy() { ?>
    <script type="text/javascript">
    (function($) {
    // Document Ready
    $(document).ready(function() {
    $('#acf-standard_region select').trigger('change');
    });
    $('#acf-standard_region .acf-taxonomy-field select').live('change', function() {
    var value = $(this).val();
    $( "#acf-standard_company:checkbox" ).addClass("compclass");
    
    if( value == "7" ) {
    $( "#acf-standard_company ul.acf-checkbox-list li ul.children li" ).removeClass( "southern no-class" ).addClass(("<?php $terms = get_the_terms( get_the_ID(), 'company'); if( !empty($terms) ) { $term = array_pop($terms); $term_id = $term->term_id; $regionVal = get_field('jobsite_region', 'company_' . $term_id ); echo $regionVal . ' ' . $term_id; } ?>"); 
    $('#acf-standard_company').show();
    $('ul.acf-checkbox-list li').show();
    }
    else if( value == "9" ) {
    
    $( "#acf-standard_company ul.acf-checkbox-list li ul.children li" ).removeClass( "northern no-class" ).addClass(("<?php $terms = get_the_terms( get_the_ID(), 'company'); if( !empty($terms) ) { $term = array_pop($terms); $term_id = $term->term_id; $regionVal = get_field('jobsite_region', 'company_' . $term_id ); echo $regionVal . ' ' . $term_id; } ?>");
    $('#acf-standard_company').show();
    $('ul.acf-checkbox-list li').show();
    }
    else {
    $( "#acf-standard_company ul.acf-checkbox-list li ul.children li" ).removeClass( "southern northern" ).addClass( "no-class" );
    $('#acf-standard_company').hide();
    $('ul.acf-checkbox-list li').hide();
    }
    
    });
    
    })(jQuery);
    </script>
    
    <?php }
    
    add_action('acf/input/admin_head', 'filter_region_taxonomy');
  • Hi Clément,

    I would guess the reason the map isn’t updated is because it does not recognise when the field is being filled programmatically. It might be solved by triggering the enter button after you’ve filled the field.

    Try something like this:

    var e = jQuery.Event("keydown");
    e.which = 50; // # Some key code value
    $("input").trigger(e);

    Are the values saved when you’re saving the post at least?

  • Yes, the code doesn’t work for me at all. When I view the source code my above code simply outputs:

    <p class"">Intro Text</p>

    It should be outputting:

    <p class"light_green">Intro Text</p>

    That way I can apply CSS styling to the ‘light_green’ class. Make sense?

  • Thanks for the feature request. I will bring this to the attention of the developer.

    ~JH

  • Thanks, that helps. Only this solution is limited to one field type this way. I would base/extend my ‘super-button-field’ on let’s say: the acf_field_page_link. If I want to also story more data (style, target, button text). I would hook into the update_value and render_field to extract the required data. And modify the html for the select and inputfields.
    Not quite what I was hoping for 🙂 no offense. But already helps a lot.

    Thanks.

  • Hi @timothy_h

    Is it possible that the taxonomy term in question contains the string ‘133’ somewhere in it’s description, slug, name or any other DB data?

  • Hi @ninjamonk

    Thanks for the info. Please let me know when you can setup an identical site.
    If no AJAX request is sent, this explains the issue. To solve it we will need to debug the JS and discover why the AJAX request was not sent.

    It could be as simple as another plugin is adding some JS which is preventing ACF from correctly functioning

  • – What is the broken plugin?

    acf

    – What is the problem?

    it does not save the post and the spinner just turns.

    Were you able to watch the AJAX request to validate the data?
    – Did the AJAX request ever return data? If so, what was the data?

    there was no network activity so no ajax was being sent.

    I will look try and recreate on a mirror of the site if you are still unable to get to the bottom of it.

  • I don’t think that globally unique field names would be an asset for everyone. For example, I build fields with the same names purposefully so that I can use the same code to retrieve them. A field group on one post type may be 50% the same as another field group on another post type. Or I may have multiple layouts that are 90% the same. With the same name I can build functions for getting the values and use them rather than different coding for every group.

    I did some testing. It is possible to change the field keys when editing the field group. This is what I did:

    • Examined the code in firebug.
    • before each field there are hidden fields in a wrapper div with a class of “meta”
    • if you remove the class name from this field you can then edit the field key in the hidden field and when you save the field group the field key will be updated to what you entered.

    I don’t know why this works, didn’t did that far. But given this it should be possible to create some custom JavaScript to remove the class from the wrapper, change the hidden field key field into a text field. Then you can change it and remove the JS when dev is done.

  • Well right now if you change a field name, you already have to resave everything in the database. So changing the key would be just the same. And, if you just required the field name to be globally unique then you wouldn’t need both a key and a name. That seems to make more sense to me anyways, as it can get confusing have two fields with the same name, but for different posts/post types, etc.

  • Sorry, I guess I didn’t quite understand. So you want to create a new field type that makes use of an existing field type but just add additional options.

    I could be wrong, but I think that what you’re really looking to do is “extend” one of the existing fields.

    Instead of this at the top of the new field class acf_field_FIELD_NAME extends acf_field

    you could extend the page link field

    class acf_field_FIELD_NAME extends acf_field_page_link

    Then I think you would only need to write new functions to replace parts of the page link field, like

    render_field
    render_field_settings
    format_value
    update_value
  • I think I ended up doing something like that in the end.

    It seems a shame that there isn’t a way. In quite a few situations it would be very helpful.

    Oh well. Thanks for responding.

  • Hi John

    I didn’t wait for an updated version of ACF to solve this issue (I posted the support request nearly 2 months ago).

    Instead I used a workaround in the form of some ACF form overrides, a custom AJAX callback, some ACF actions and some WordPress AJAX actions. This sends its own modified AJAX request to ACF, and some hooks perform some overrides to return JSON objects (for validation and saving respectively) rather than just redirecting. Then I was able to capture that data to do whatever I wanted (in this case displaying a success message rather than redirecting).

    See the following code sample: http://pastebin.com/L55bNyu7

    Cheers

  • The best solution to this would be to have an “Options” page using ACF Pro (or the options page add on which is still available for ACF4 http://www.advancedcustomfields.com/add-ons/)

    Then you can create an options page, add you custom field group to the options page and then pull the values from the options page for all of your pages.

    Without using an options page you would need to use the acf/save_post hook http://www.advancedcustomfields.com/resources/acfsave_post/

    You could do a query in you function to get all the pages and then update all of the fields on all of the pages.

  • Not sure if you’re still having problems with this, trying to clear up older questions.

    Are you still seeing the problem of the form submission hanging instead of redirecting with the newest version of ACF?
    What browser are you seeing this in?

  • Ah. Yes I plan on running a little script called color thief (https://github.com/lokesh/color-thief/) I will save the values generated from the script and use it for styling.

    Actually, wp.media.gallery exist, but can’t see any attachments to it, hm. wp.media.gallery.attachments exist but only links to a function in media-edtior.js:

    * @param {wp.shortcode} shortcode An instance of wp.shortcode().
    * @returns {wp.media.model.Attachments} A Backbone.Collection containing
    * the media items belonging to a collection.
    * The query[ this.tag ] property is a Backbone.Model
    * containing the ‘props’ for the collection.

  • Thanks John, I modified it a bit so this is what it looks like now (works perfectly!):

    <?php if( have_rows('resources_column') ): ?>
                
                    <?php while( have_rows('resources_column') ): the_row(); 
                        // variables
                        $title = get_sub_field('resource_title');
    					$internal_link = get_sub_field('resource_internal_link');
    					$external_link = get_sub_field('resource_external_link');
                        $description = get_sub_field('resource_description');
    					$resource_link_type = get_sub_field('resource_link_type');
    					if ($resource_link_type == 'internal') {
    						$link = get_sub_field('resource_internal_link');
    					} else {
    						$target = ' target="_blank" rel="nofollow"';
    						$link = get_sub_field('resource_external_link');
    					}
    				?>
                    
    				<p class="resource-title"><a href="<?php echo $link; ?>"<?php echo $target; ?>><?php echo $title; ?></a></p>
                    <p class="resource-description"><?php echo $description; ?></p>
    
                    <?php endwhile; ?>
                
                <?php endif; ?>
  • 
    $resource_link_type = get_sub_field('resource_link_type');
    if ($resource_link_type == 'internal') {
      $target='self';
      $link = get_sub_field('resource_internal_link');
    } else {
      $taget = '_blank';
      $link = get_sub_field('resource_external_link');
    }
    ?>
    <a href="<?php echo $internal_link; ?>" target="<?php echo $target; ?>">
    
  • Thank you Johnathan! That did the trick! I was so close to the code you just posted, just wasn’t quite there yet.

  • Hi @cjf9

    You need to do the same for the tax field as with all your others and set the second parameter the same way.

    
    <?php 
    $queried_object = get_queried_object(); 
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;  
    $related_terms = get_field('quick_links', $taxonomy . '_' . $term_id);
    if( $related_terms ): ?>
    
    	<ul>
    
    	<?php foreach( $related_terms as $related_term ): ?>
    
    		<a href="<?php echo get_term_link( $related_term ); ?>"><?php echo $related_term->name; ?></a>
    
    	<?php endforeach; ?>
    
    	</ul>
    
    <?php endif; ?>
    
    
  • thanks for the reply however

    after trying this:

    <?php

    $image = get_field(‘client_2_image’);

    if( !empty($image) ): ?>
    ” alt=”<?php echo $image[‘alt’]; ?>” title=”working”/>

    <?php endif; ?>

    I get the following error…

    <img src="<br />
    <b>Warning</b>:  Illegal string offset 'url' in <b>C:\xampp\htdocs\wordpress-4.1.1\wordpress\wp-content\themes\byersenterprises\page.php</b> on line <b>161</b><br />
    h" alt="<br />
    <b>Warning</b>:  Illegal string offset 'alt' in <b>C:\xampp\htdocs\wordpress-4.1.1\wordpress\wp-content\themes\byersenterprises\page.php</b> on line <b>161</b><br />
    h" title="working">

    it grabs the right image as I added this code to echo the info:
    <?php echo $image, the_field(‘client_2_image’) ?>

    and both are the same url, but no, alt and the url does not work.

Viewing 25 results - 16,601 through 16,625 (of 21,397 total)