Tagged: 

Viewing 8 reply threads
  • Author
    Posts
    • #1660
      pupppet
      Member

      Two questions on post-relate:

      – Is conditionally showing/hiding a post-relate field unsupported? Adding a condition to it doesn’t do anything, it always remains visible.
      – Is it possible to include multiple post types in the scope?

    • #1679
      Steve
      Keymaster

      @pupppet– Showing/hiding seems to be a bug with the relate field. Supporting multiple scopes is interesting. I just tested multiple scopes like this 'scope' => array('post','page') and it seemed to work, but throws a bunch of warnings since most Piklist functions are not expecting an array. We’re going to have to think through if, and how, we want to support this.

    • #1682
      Jason
      Keymaster

      I’m trying to think through a context in which it would be advantageous to have a single post-relate field with multiple post types versus a field for each one. I mean, Piklist aside, you get one field per taxonomy.

      @puppet – Is there a reason to merge them instead of splitting them into multiple fields?

    • #1683
      pupppet
      Member

      If we can get that conditional post-relate field bug fixed, there wouldn’t be a need to split them up as you could show/hide whichever post-relate is required. But I could see a situation where you may want multiple post types in the single post-relate field, for example if you have a large number of post types you aren’t necessarily going to want to have a large number of these post-relate fields conditionally showing/hiding, you’re bogging down the client with a lot of near duplicate code (not that it’s the end of the world or anything). ACF5 has a nifty post type dropdown to filter post-types you can include in its equivalent of Piklist’s post-relate field, might be a nice thing to copy.

    • #3299
      dryan1144
      Member

      Can I crack this thread open again? I’m trying to get a Post Relate field to show conditionally and ran into this bug – in my case the Post Relate field stays hidden no matter what selection is made on the controlling field.

    • #3300
      Steve
      Keymaster

      Please post your field code

    • #3301
      dryan1144
      Member
      
      piklist('field', array(
        		   'type' 		=> 'radio',
      		   'field' 		=> 'portfolio_type',
      		   'label' 		=> __('Company Type'),
      		   'description' 	=> __('Select a Type'),
      		   'value'		=> 'platform',
      		   'choices'		=> array(
      			   	'platform'	=> 'Platform',
      			   	'addon'		=> 'Add-on',
      			)
      ));
      
      piklist('field', array(
          'type' 		=> 'post-relate',
          'scope' 		=> 'portfolio',
          'label' 		=> 'Add Ons',
          'conditions' 	=> array(
            array(
              'field'  => 'portfolio_type',
              'value'  => 'platform'
      	)
            )
      ));
      
      
    • #3302
      Steve
      Keymaster

      @dryan1144

      Yup… this still doesn’t work 😉

      We currently rethinking the Post Relate field. If you need this type of functionality right away, you may want to try a standard checkbox:

        piklist('field', array(
          'type'     => 'checkbox',
          'field'    => 'portfolio_relate',
          'label'    => __('Add Ons'),
          'value'    => 'platform',
          'choices' => piklist(
            get_posts(
               array(
                'post_type' => 'post'
                ,'orderby' => 'post_title'
               )
               ,'objects'
             )
             ,array(
               'ID'
               ,'post_title'
             )
          ),
          'conditions'  => array(
            array(
              'field'  => 'portfolio_type',
              'value'  => 'platform'
            )
          )
        ));
      

      Let us know if that works for you.

    • #3303
      dryan1144
      Member

      Thanks for the code – it works well enough except for the fact that the list of options can easily get ridiculously long in this particular situation. Unless we set a height on the checkbox container and scroll…

      Interested to see what you guys have coming for the Post Relate field, it’s one I use often. I’m sure you’ve seen how CMB/CMB2 does theirs – basically a search/dropdown select with a repeater field. Really nice UI.

      Thanks for the help.

Viewing 8 reply threads
  • You must be logged in to reply to this topic.