Forum Replies Created
-
AuthorPosts
-
mcmasterMemberOkay, so I defined a CSS class and put it into a file in the parts/css folder:
.mcw-editor-short { height: 140px; }And then I added
editor_classto an editor field:array( 'type' => 'editor', 'field' => 'newsletter_highlights', 'label' => __( 'Highlights of this issue' ), 'columns' => 12, 'options' => array ( 'media_buttons' => false, 'editor_class' => 'mcw-editor-short', 'teeny' => true, ), ),But the class is applied to a textarea that is
display: none, so it doesn’t affect the height of the editor box. See attached Firebug screenshot.Again, could be pilot error … so set me straight if I’m goofing up! 🙂
Donna
Attachments:
You must be logged in to view attached files.
mcmasterMemberAnd I know I can use
editor_class. Just wondering if there is a method that doesn’t require setting up a CSS file. Lazy. 😉
mcmasterMemberAlso, is there a better way to limit the height of an editor field? I tried
'attributes' => array ( 'rows' => 3, ),But that doesn’t work.
Thanks!
Donna
mcmasterMember@Steve, thanks for the reminder about columns. I must confess I’ve never taken the time to figure out how they work. :-/ Will do that today!
mcmasterMemberSince it won’t allow me to upload the .php file, here’s the field definition:
piklist('field', array( 'type' => 'group', 'field' => 'newsletter_archive', 'label' => 'Newsletter Archives', 'description' => 'Each archive includes an image, title and section for highlighting the content of the newsletter.', 'columns' => 12, 'add_more' => true, 'template' => 'field', 'fields' => array( array( 'type' => 'text', 'field' => 'newsletter_archive_title', 'label' => 'Issue Date', ), array( 'type' => 'file', 'field' => 'newsletter_file', 'label' => 'Upload or choose a PDF', 'options' => array( 'modal_title' => 'Add File(s)', 'button' => 'Add', ), ), array( 'type' => 'editor', 'field' => 'newsletter_highlights', 'label' => __( 'Highlights of this issue' ), 'options' => array ( 'wpautop' => true, 'media_buttons' => false, 'tabindex' => '', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true, ), ), array( 'type' => 'file', 'field' => 'newsletter_image', 'label' => 'Add a cover image', 'options' => array( 'modal_title' => 'Add File(s)', 'button' => 'Add', ), ), ), ));
mcmasterMemberThanks, Steve! Heading for California first thing in the morning so I’ll have to let someone else test this one. 😉 By the time I’m back on the web Saturday morning you’ll probably have another release!
mcmasterMemberOne tip for anyone who has defined piklist fields inside their theme.
In order to deactivate Piklist, I renamed my theme’s piklist file to piklistx. Then I switched to the new Piklist plugin files, reactivated it, and ran the update. Oops, it didn’t find my theme’s piklist parts so it didn’t run the update on them.
So if you use this method to deactivate Piklist before the upgrade, make sure you switch the name back before running the database update.
#creativewaystomessup
mcmasterMemberOn a hunch, I decided to try it with 0.9.9, and it works. So maybe the functionality got lost in 0.9.9.1?
mcmasterMember@erikkubica, oh yes, I am also quite good at making my solutions more complex than the problems 🙂
mcmasterMemberThanks, @Steve. But I just realized I got it backwards. I think @erikkubica wants:
if ( !$post->post_parent ) { // define fields here }It’s those details that always bite me! 🙂
mcmasterMemberI think the simplest way is to enclose the field definition in an “if” statement.
if ( $post->post_parent ) { // define fields here }You may need to declare $post as a global.
global $post;Donna
mcmasterMemberp.s. If you looked closely, you probably figured out that the preg_match phrase doesn’t work. I ended up going in a different direction as all I really wanted to do was remove the dollar sign if someone entered it with the amount. So in case it’s helpful, here’s what I’m using:
$number = str_replace( '$', '', $value); $number = (int)$number;
mcmasterMemberThen I found this page: https://piklist.com/user-guide/docs/piklist_sanitization_rules/
So I added a ‘piklist_sanitization_rules’ filter and created a rule for ‘mcw_integer’, using the same callback function:add_filter( 'piklist_sanitization_rules', 'mcw_add_sanitize_rule', 11 ); function mcw_add_sanitize_rule ( $sanitization_rules ) { $sanitization_rules['mcw_integer'] = array( 'callback' => 'mcw_sanitize_integer' ); return $sanitization_rules; } function mcw_sanitize_integer ( $value, $field, $options ) { $number = preg_match( '/^[0-9]+$/', $value ); $number = (int)$number; if ( isset( $options['non_negative'] ) && $options['non_negative'] && ( $number < 0 ) ) { return '0'; } else { return "$number"; } }I changed the field definition to:
piklist('field', array( 'type' => 'text', 'field' => 'donation', 'scope' => 'post_meta', 'value' => '', 'template' => 'mcw_quantity', 'label' => 'Amount of Donation', 'sanitize' => array( array( 'type' => 'mcw_integer', 'options' => array( 'non_negative' => true, ), ), ), 'required' => false, ));The good news is that it does call the callback function. But it kept giving me an error message: ‘PHP Notice: Undefined index: type in /…/wp-content/plugins/piklist/includes/class-piklist-validate.php on line 304
But of course, now that I’m reporting this, the error message has gone away. So it looks as though the second model is working.
It would be really helpful to have one complete example that shows both ends of the process, and I would like to know what I did wrong with my first attempt.
Thanks! 🙂
mcmasterMemberFirefox hung, so I restarted it. And now the excerpt is showing up as WYSIWYG. Go figure!
mcmasterMemberThanks for the explanation, Steve. This one’s on my wishlist, too.
-
AuthorPosts