google-code-export / wordpress-custom-content-type-manager

Automatically exported from code.google.com/p/wordpress-custom-content-type-manager
2 stars 1 forks source link

Display custom fields conditionally #481

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Would like to display custom fields conditionally based on page template. 

When adding a custom field, display a dropdown menu where you can choose a 
corresponding page template(s) when the current custom field would be displayed 
in the admin. Otherwise the custom field would not be visible in the Admin 
while editing a post.

Would come in handy, if you just want to add extra WYSIWYG's for the sites 
frontpage and have no need for them on subpages.

Types-plugin has this functionality, but i don't like to use it so much as 
CCTM: http://wp-types.com/

Original issue reported on code.google.com by tra...@gmail.com on 26 Apr 2013 at 1:10

GoogleCodeExporter commented 9 years ago
Hmm... the whole push with the CCTM is that the post-type determines which 
fields are available.  The template is arbitrary because it's downstream of the 
data model.  WP does some bad stuff with its architecture, and altering the 
fields via a changed template is the wrong way to do it in my opinion.  
Architecturally, the simple and "correct" way to do this would be to have all 
available fields visible in the manager screens and just hide/show the desired 
fields in the templates.

Even if you wanted to integrate this feature, WP's way of supporting templates 
is so whacked as to make this type of thing difficult.  I see what you're 
getting at, but I need to think this over a bit... it would require one more 
level of abstraction, and Issue #19 would have to completed as a prerequisite, 
but even then I feel like it's putting the carriage before the horse.

Original comment by ever...@fireproofsocks.com on 26 Apr 2013 at 1:21

GoogleCodeExporter commented 9 years ago
A GUI for this would be overwraught I think (too much cleaning of WP warts).  
Perhaps some info could be added to the configuration file(s) to handle this.

Original comment by ever...@fireproofsocks.com on 2 May 2013 at 1:51

GoogleCodeExporter commented 9 years ago
See also issue #7.

Original comment by ever...@fireproofsocks.com on 19 Jul 2013 at 5:40

GoogleCodeExporter commented 9 years ago
You can do this by hiding metaboxes.  When you create a metabox in the CCTM, 
add some PHP to its "Visibility Control" box, e.g.

return basename( get_page_template() ) == "page-about.php"

If the statement evaluates to true, the metabox (and the fields it contains) 
will be displayed.  If it evaluated with false, the metabox will not show.

Original comment by ever...@fireproofsocks.com on 4 Feb 2014 at 7:20

GoogleCodeExporter commented 9 years ago
Hey

How can I use the Visibility function in order to show the box, only on certain 
page type, or pos/page/custom_type ID.
Like "show this metabox while the page with ID 45 is edited?"

Original comment by 2...@2046.cz on 3 Feb 2015 at 2:44

GoogleCodeExporter commented 9 years ago
Currently the boxes and fields are tied to a post-type, not to a specific post. 
 Is that what you mean?

Original comment by ever...@fireproofsocks.com on 3 Feb 2015 at 3:43