Forum Replies Created

Viewing 15 posts - 31 through 45 (of 71 total)
  • Author
    Posts
  • in reply to: Editor field in nested add-more: Fixed, but… #3013
    cosmocanuck
    Member

    The second group of recipe steps now produces text editor boxes that I can at least type into, which is good. But the toolbar is missing. The initial, first group of steps has perfectly functional text editor boxes.

    Here’s the code for my metaboxes. It’s the “recipe_step” field within the “steps_section” group that’s giving me grief…

    <?php
    /*
    Title: Recipe Details
    Post Type: recipe
    Priority: high
    */
    
    piklist('field', array(
        'type' => 'editor'
        ,'field' => 'recipe_description'
        ,'template' => 'field'
        ,'label' => __('Description')
        ,'description' => __('Brief description/summary of the recipe')
        ,'options' => array(
    		'drag_drop_upload' => 'false'
    		,'tinymce' => true
    		,'quicktags' => true
      		)
    ));
    
    piklist('field', array(
        'type' => 'text'
        ,'field' => 'recipe_serves'
        ,'label' => __('Servings')
        ,'description' => __('For example, "3-4"')
    	 ,'attributes' => array(
    	   'class' => 'text'
    	 )
    ));
    
    piklist('field', array(
       'type' => 'group'
       ,'field' => 'ingredient_section'
       ,'label' => __('Ingredients')
       ,'description' => __('Add additional Section if a recipe has separate listings for different parts, i.e. the salad and the dressing.')
       ,'add_more' => true
       ,'fields' => array(
    					array(
    				   'type' => 'html'
    				   ,'label' => __('Ingredient section')
    				   ,'columns' => 12
    				   ,'value' => '<p><em><strong>Note:</strong> for consistency, please only capitalize sentences and Superior product names; otherwise keep all text lower case.</em></p>'
    				   ,'attributes' => array(
    					 'class' => 'recipe-subhead'
    										)
    					 )
    				 
    					 ,array(
    						'type' => 'text'
    						,'field' => 'ingredients_component_title'
    						,'label' => __('Section Title (can be omitted for first section, or if there&rsquo;s only one)')
    						,'columns' => 12
    						)
    				 
    					 ,array(
    					   'type' => 'group'
    					   ,'field' => 'ingredient'
    					   ,'add_more' => true
    					   ,'fields' => array(
    							 array(
    							   'type' => 'text'
    							   ,'field' => 'ingredient_qty'
    							   ,'label' => __('Qty')
    							   ,'columns' => 2
    							 )
    							 ,array(
    							   'type' => 'textarea'
    							   ,'field' => 'ingredient_descrip'
    							   ,'label' => __('Description')
    							   ,'columns' => 10
    							 )
    				   		)
    				 )
       )
     ));
     
     piklist('field', array(
       'type' => 'group'
       ,'field' => 'steps_section'
       ,'label' => __('Steps')
       ,'description' => __('Do not add numbers to the steps; they\'ll be added automatically.')
       ,'add_more' => true  
       ,'fields' => array(
       
       
       
    					array(
    				   'type' => 'html'
    				   ,'label' => __('Group of steps')
    				   ,'columns' => 12
    				   ,'value' => ''
    				   ,'attributes' => array(
    					 'class' => 'recipe-subhead'
    										)
    					 )
    	
    		
    				 	,array(
    						'type' => 'text'
    						,'field' => 'steps_component_title'
    						,'label' => __('Section Title (can be omitted if there&rsquo;s only one section)')
    						,'columns' => 12
    					)
    
    					 ,array(
    					   'type' => 'group'
    					   ,'field' => 'step_group'
    					   ,'add_more' => true
    					   ,'fields' => array(
    								array(
    								'type' => 'editor'
    					   			,'add_more' => true
    								,'field' => 'recipe_step'
    								,'options' => array (
    									  'wpautop' => true
    									  ,'media_buttons' => false
    									  ,'tabindex' => ''
    									  ,'tinymce' => true
    									  ,'quicktags' => false
    									  )
    								)
    
    				   		)
    				)
    	)
    
     ));
    in reply to: Height of textarea field – how to control? #3012
    cosmocanuck
    Member

    Thanks for clarifying, Steve!

    in reply to: Editor field in nested add-more: Fixed, but… #2987
    cosmocanuck
    Member

    Hi Steve! I upgraded, and now I’m afraid even my “fix” (which perhaps was not reliable anyway) no longer works. New “recipe step” editor fields in a second section, come up unclickable and with no toolbar.

    It’s not super critical right now for me, as most recipes, even if they have multiple ingredient groups, only have a single list of steps. But I want to of course be prepared for any eventuality! So do keep me posted, and I’ll keep upgrading and testing as I see the new versions arrive.

    in reply to: Nested groups problem #2909
    cosmocanuck
    Member

    Thank YOU! It’s an honour!

    in reply to: Displaying add-more fields #2908
    cosmocanuck
    Member

    Yikes! The notorious “missing comma syndrome”… bane of programmers everywhere. Thanks so much, and this should really help me with issues like this in the future.

    It must be one of the perils of piecemeal WP learning, but it never was evident how useful or important WP_Debug was! Though I know how important debugging tools are in principle, I’ve never used that function. That will now change.

    Thanks again.

    in reply to: Displaying add-more fields #2899
    cosmocanuck
    Member
    This reply has been marked as private.
    in reply to: Displaying add-more fields #2890
    cosmocanuck
    Member

    Thanks so much Steve! That’s so bizarre. Maybe special/nonstandard characters had crept into the file or something…

    At least I know the code was NOT the problem, so that’s helpful. If it reoccurs, I’ll try your “solution”!

    Thanks again,
    adam

    in reply to: Displaying add-more fields #2884
    cosmocanuck
    Member
    This reply has been marked as private.
    in reply to: Displaying add-more fields #2881
    cosmocanuck
    Member
    This reply has been marked as private.
    in reply to: Displaying add-more fields #2879
    cosmocanuck
    Member

    Thanks Steve.

    Was get_post_custom() previously the recommended way to pull in (non-repeating) fields? Because that’s how I did it on the previous site, the first one I used Piklist with; as per my earlier post, the code looks like this:

    $data = get_post_custom($post->ID);
    echo $data [recipe_description][0];

    I’m sure I got that method from somewhere in the Piklist support section, but now when I look at the page about metaboxes and fields:

    https://piklist.com/user-guide/tutorials/creating-meta-boxes-fields/

    I see that get_post_meta is indeed the method given for pulling in your field data.

    And I’d use it, but for the fact that I can’t for the life of me get it to work!

    I tried putting your sample code in my template, modified to refer to my Recipe field group seen in a prior post:

    // Grab the data two different ways
    $get_post_meta = get_post_meta($post->ID, 'ingredient_section', true);
    $get_post_custom = get_post_custom($post->ID);
    
    // Display the data
    print_r($get_post_meta);
    print_r($get_post_custom['ingredient_section']);

    When I do so, the first print_r returns absolutely nothing, but the second one (using the non-recommended method) at least spits out all the recipe ingredients! (Albeit in that awkward array format).

    I can’t figure out how I am screwing up the use of get_post_meta. Argh!

    You’ve been very patient and helpful so I hate to keep asking, but even having studied the Codex on this, I”m just getting nowhere. Hope you can advise.

    Thanks!

    in reply to: Nested groups problem #2876
    cosmocanuck
    Member

    Oh, BTW, please could you delete my post with the Dashboard access info? I meant to set that as private… don’t want it on the forums of course.

    Last but not least, as requested, here’s my final working code for the full “recipe entry” form:

    <?php
    /*
    Title: Recipe Details
    Post Type: recipe
    Priority: high
    */
    
    piklist('field', array(
        'type' => 'editor'
        ,'field' => 'recipe_description'
        ,'template' => 'field'
        ,'label' => __('Description')
        ,'description' => __('Brief description/summary of the recipe')
        ,'options' => array(
    		'drag_drop_upload' => 'false'
    		,'tinymce' => true
    		,'quicktags' => true
      		)
    ));
    
    piklist('field', array(
       'type' => 'group'
       ,'field' => 'ingredient_section'
       ,'label' => __('Ingredients')
       ,'description' => __('Add additional Section if a recipe has separate listings for different parts, i.e. the salad and the dressing.')
       ,'add_more' => true
       ,'fields' => array(
    					array(
    				   'type' => 'html'
    				   ,'label' => __('Ingredient section')
    				   ,'columns' => 12
    				   ,'value' => '<p><em><strong>Note:</strong> for consistency, please only capitalize sentences and Superior product names; otherwise keep all text lower case.</em></p>'
    				   ,'attributes' => array(
    					 'class' => 'recipe-subhead'
    										)
    					 )
    				 
    					 ,array(
    						'type' => 'text'
    						,'field' => 'ingredients_component_title'
    						,'label' => __('Section Title (can be omitted for first section, or if there&rsquo;s only one)')
    						,'columns' => 12
    						)
    				 
    					 ,array(
    					   'type' => 'group'
    					   ,'field' => 'ingredient'
    					   ,'add_more' => true
    					   ,'fields' => array(
    							 array(
    							   'type' => 'text'
    							   ,'field' => 'ingredient_qty'
    							   ,'label' => __('Qty')
    							   ,'columns' => 2
    							 )
    							 ,array(
    							   'type' => 'textarea'
    							   ,'field' => 'ingredient_descrip'
    							   ,'label' => __('Description')
    							   ,'columns' => 10
    							 )
    				   		)
    				 )
       )
     ));
     
     piklist('field', array(
       'type' => 'group'
       ,'field' => 'steps_section'
       ,'label' => __('Steps')
       ,'description' => __('Do not add numbers to the steps; they\'ll be added automatically.')
       ,'add_more' => true  
       ,'fields' => array(
       
       
       
    					array(
    				   'type' => 'html'
    				   ,'label' => __('Group of steps')
    				   ,'columns' => 12
    				   ,'value' => ''
    				   ,'attributes' => array(
    					 'class' => 'recipe-subhead'
    										)
    					 )
    	
    		
    				 	,array(
    						'type' => 'text'
    						,'field' => 'steps_component_title'
    						,'label' => __('Section Title (can be omitted if there&rsquo;s only one section)')
    						,'columns' => 12
    					)
    
    					 ,array(
    					   'type' => 'group'
    					   ,'field' => 'ingredient'
    					   ,'add_more' => true
    					   ,'fields' => array(
    							 array(
    								'type' => 'textarea'
    								,'field' => 'recipe_step'
    								,'label' => __('Recipe Step')
    								,'columns' => 12
    								,'add_more' => true
    							 )
    				   		)
    				)
    	)
    
     ));
    in reply to: Nested groups problem #2875
    cosmocanuck
    Member

    Thanks Steve. I finally realized what I did – I didn’t keep the ingredient steps within a Group field as I’d done for the Qty/Ingredient pairs. I’d thought that being a single repeating field, it would stay in its containing Group, but clearly it needed to still be in a group even if is only one repeating item, not a set.

    And, I’d say this support thread is done! I may have another for you about displaying the nested data… but I’ll start that up separately if needed. 8^)

    Thanks!

    in reply to: Nested groups problem #2873
    cosmocanuck
    Member

    OK, this is not a panic but a real problem, hopefully just a code error but for the life of me I can’t find it!

    I duplicated the same overall structure that works for the ingredients, into the instructions area. So, I can have multiple “groups” of instructions if necessary.

    However, when I add multiple steps – when I save the post, each step gets wrapped in its own “group” even though I did not add any additional groups!

    Here’s my code for that section, as it currently stands. Login info if you need it, is in the above post in this thread.

    Thanks!

    piklist('field', array(
       'type' => 'group'
       ,'field' => 'steps_section'
       ,'label' => __('Steps')
       ,'description' => __('Do not add numbers to the steps; they\'ll be added automatically.')
       ,'add_more' => true  
       ,'fields' => array(
    					array(
    				   'type' => 'html'
    				   ,'label' => __('Steps section')
    				   ,'columns' => 12
    				   ,'value' => ''
    				   ,'attributes' => array(
    					 'class' => 'recipe-subhead'
    										)
    					 )
    	
    	
    	
    	
    				 	,array(
    						'type' => 'text'
    						,'field' => 'steps_component_title'
    						,'label' => __('Section Title (can be omitted if there&rsquo;s only one section)')
    						,'columns' => 12
    					)
    
    					 ,array(
    						'type' => 'textarea'
    						,'field' => 'recipe_step'
    						,'label' => __('Recipe Step')
    						,'columns' => 12
    						,'add_more' => true
    				 	 )
    				 	 
    				 	 
    				 	 
    				 	 	 
    	
       				)
     ));
    in reply to: Nested groups problem #2872
    cosmocanuck
    Member

    Never mind! It was the code, I hadn’t noticed the qty was set to a “Number” field, so it was stripping out the content when I added text to that field. It actually needed to be a text field since the quantity often includes words, i.e. “1 tsp”.

    Sorry about the panic!

    in reply to: Nested groups problem #2870
    cosmocanuck
    Member

    Sure, Steve! Here you go:

    piklist(‘field’, array(
    ‘type’ => ‘group’
    ,’field’ => ‘component’
    ,’label’ => __(‘Components’)
    ,’description’ => __(‘Add additional Components if a recipe has separate listings for different parts, i.e. the salad and the dressing.’)
    ,’add_more’ => true
    ,’fields’ => array(
    array(
    ‘type’ => ‘html’
    ,’label’ => __(‘Ingredients’)
    ,’help’ => __(‘For consistency, please only capitalize sentences and Superior product names; otherwise keep all text lower case.’)
    ,’columns’ => 12
    ,’attributes’ => array(
    ‘class’ => ‘large-text’
    )
    )

    ,array(
    ‘type’ => ‘text’
    ,’field’ => ‘component_title’
    ,’label’ => __(‘Component Title (optional for 1st)’)
    ,’columns’ => 12
    )

    ,array(
    ‘type’ => ‘group’
    ,’field’ => ‘ingredient’
    ,’add_more’ => true
    ,’fields’ => array(
    array(
    ‘type’ => ‘number’
    ,’field’ => ‘ingredient_qty’
    ,’label’ => __(‘Qty’)
    ,’columns’ => 2
    )
    ,array(
    ‘type’ => ‘textarea’
    ,’field’ => ‘ingredient_descrip’
    ,’label’ => __(‘Description’)
    ,’columns’ => 10
    )
    )
    )
    )
    ));

Viewing 15 posts - 31 through 45 (of 71 total)