Support

Account

Forum Replies Created

  • There’s definitely interest, I’m working on a plugin that will allwo HTML, CSS an JS to be entered. Mixed code would be something I’d like to see. As far as PHP goes though, I don’t let people do PHP through the admin, so not needed.

  • Didn’t even know it existed, I’ll give it a try.

    There do seem to be some limitations that’ll effect it’s use and from giving it a quick look it doesn’t seem to be supported at all.

  • Just in case anyone else needs this information.

    So, to create an arbitrary number of subfields for a new post, if I have a repeater named “bf_test_repeater”

    
    add_filter('acf/load_value/name=bf_test_repeater',  'afc_load_bf_test_repeater_value', 10, 3);
    function afc_load_bf_test_repeater_value($value, $post_id, $field) {
      if ($value === false) {
        // this is a new post since value === false
        // set value to number of default # of rows to create
        $value = 5;
      }
      return $value;
    } 
    

    I’ll have more code than this since it will need to figure out by looking at the options page how many rows to start with. Then I’ll need the code for each of the sub-fields to set the value to the next value retrieved from the options page.

  • I’m guessing that my problem was/is that there are no subfields to begin with in what I was trying.

    I just did this on another repeater that has a minimum number of subfields that must be set and it works fine.

    So what I guess I really need to figure out is how to dynamically create some arbitrary number of subfield rows when a new post is being created.

  • I’ve tried using acf/load_value, but I’m missing something when it comes to the subfields of a repeater. Heh, I’ve figured out how to populate default content in in almost every other type of field but this one has me stumped for some reason ๐Ÿ˜›

    Do I add the filter for the repeater field or each of the subfields?

  • I guess I need to wait, no export to PHP yet. There is a bug in the export as it is, I’ll post that to issues on github

  • I’m working on creating a duplicate of the R&D site I am working on the new plugin on. I’ll try install/update to ACF5 there and see how the export works, among other things.

    I’ve been trying to watch the progress on ACF5, there were a few missing features the last time I looked that I really need to have to work on this plugin.

  • Heh, and all my nice coding was altered here as well, see if this works I enter & lt ; (remove the spaces) and it is exported as <

  • In the above code
    'capability_type' => 'page'
    is what caused the problem, if I change that to post, then there isn’t a problem.

    For now I’m using ‘post’, It isn’t a huge difference in this case. Really just wanted people to be aware of it.

  • register_post_type($this->slug,
      array('label' => 'Supplemental Content',
           'public' => false,
           'show_ui' => true,
           'show_in_menu' => true,
           'show_in_nav_menus' => false,
           'capability_type' => 'page',
           'hierarchical' => false,
           'rewrite' => false,
           'query_var' => true,
           'exclude_from_search' => true,
           'menu_position' => $this->options['post_type']['menu_position'],
           'supports' => $this->options['post_type']['supports'],
           'labels' => array ('name' => 'Supplimental Content',
                              'singular_name' => 'Page',
                              'menu_name' => 'Supplimental Content',
                              'add_new' => 'Add Page',
                              'add_new_item' => 'Add New Page',
                              'edit' => 'Edit',
                              'edit_item' => 'Edit Page',
                              'new_item' => 'New Page',
                              'view' => NULL,
                              'view_item' => NULL,
                              'search_items' => 'Search Pages',
                              'not_found' => 'No Pages Found',
                              'not_found_in_trash' => 'No Pages Found in Trash'),
           'description' => 'This post type has been added by the plugin 
                            "Supplimental Content". It allows the user to create 
                            content that can be added to archive pages on the site. 
                            For more information read the documentation for the plugin.'));
  • As you can see in this first image, when the capability_type of the custom post type is “post” you can select a specific post to add the field group to.
    Image 1
    In these next two the capability_type of the custom post has been changed to page page then a specific post cannot be selected, unless I’m still missing something.
    image2
    image2

  • Figured this out for anyone that has the same problem.

    When creating a custom post type, if you want to be able to choose specific posts in the post type then the value of the argument ‘capability_type’ must be ‘post’

    Not sure if this was intended or not.

  • Great, thanks for the reply. I’ll probably stick with slightly altering whatever was created as the key when the field was created. Easy enough to use a preg_match to grab the fields and then duplicate and alter.

  • Actually, I believe what you want to do may be possible. I have run into a similar need.

    In my case I have a custom post type and in that post the user can set the item as either active or inactive. When they select inactive they are then shown a select box where they can select an alternate item to use in its place. I could have used the Post Object or Relationship type field for this, however, this would allow them to select another item that was also inactive. I did not want to do this because it would just confuse them and make them do the work of selecting an active item.

    Then I found this tutorial: Dynamically populate a select fieldโ€™s choices
    http://www.advancedcustomfields.com/resources/tutorials/dynamically-populate-a-select-fields-choices/

    (sorry for the long link, for some reason the editor would not allow me to add the link the right way.)

    Anyway, the tutorial shows you how to use an options field to populate a select box. However, with a little work I was able to change it to a query to get only the items that are marked as active and built my own select that way. I have found this useful several times with the current project I’m working on.

    You might be able do the something similar but in your case you can create a query that gets a list of the projects and then a loop to pull the list of images in each project. Then your user could select from that. Unfortunately there might be more work because you would only be able to add text to the select field to choose from and I don’t think you can show the actual images in the select field so it may not be a perfect workaround.

  • @WazzaJB

    Worked a charm, added your code to my custom plugin class for this site. I have not tested it completely, only tested to see if it worked on the parent level so far. Will test the rest as I use it. But after reading the instructions that Elliot linked to and looking at your code I don’t see why it wouldn’t work.

    Thanks a heap, saved me a boatload of time trying to figure it out on my own. Now I have an example to follow ๐Ÿ™‚

  • Thanks, I’ll give it a whirl and let you know how it goes.

Viewing 17 posts - 14,451 through 14,467 (of 14,467 total)