- This topic has 9 replies, 2 voices, and was last updated 6 years, 7 months ago by
Steve.
-
AuthorPosts
-
-
July 1, 2015 at 11:25 am #3944
sancreativeMemberI’ve created a grouped field in a settings page
something similar to this:piklist('field', array( 'type' => 'group' ,'label' => 'Headings' ,'field' => 'global_headings_style_group' ,'list' => false ,'description' => 'Set the Template Layout Options' ,'fields' => array( array( 'type' => 'text' ,'field' => 'global_custom_h1' ,'label' => 'H1 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ,array( 'type' => 'text' ,'field' => 'global_custom_h2' ,'label' => 'H2 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ) ));what is the easiest way to display on frontend?
-
July 1, 2015 at 12:07 pm #3946
sancreativeMemberIt would be easier if i could just display them without having to group the fields to get them to show.
but whenever I ungroup the fields it will only display the last ‘ungrouped’ group
not sure if this is a bug or if there is a way around this – ive tried absolutely everything with the options to get them to show. -
July 1, 2015 at 1:47 pm #3947
SteveKeymasterYou can remove
'field' => 'global_headings_style_group', if you want and the other fields will save as normal. Let us know if that works for you. -
July 1, 2015 at 1:56 pm #3948
sancreativeMemberIt works if I only want one ungrouped group on one settings page
if i add two to the same page it renders the 2nd and not the 1st.piklist('field', array( 'type' => 'group' ,'label' => '1st' ,'description' => 'An Un-grouped field. Data is saved as individual meta and is searchable.' ,'fields' => array( array( 'type' => 'text' ,'field' => 'custom_h1' ,'label' => 'H1 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ,array( 'type' => 'text' ,'field' => 'custom_h2' ,'label' => 'H2 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ,array( 'type' => 'text' ,'field' => 'custom_h3' ,'label' => 'H3 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ,array( 'type' => 'text' ,'field' => 'custom_h4' ,'label' => 'H4 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ,array( 'type' => 'text' ,'field' => 'custom_h5' ,'label' => 'H5 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ) )); piklist('field', array( 'type' => 'group' ,'label' => '2nd' ,'description' => 'An Un-grouped field. Data is saved as individual meta and is searchable.' ,'fields' => array( array( 'type' => 'text' ,'field' => 'custom_h1' ,'label' => 'H1 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ,array( 'type' => 'text' ,'field' => 'custom_h2' ,'label' => 'H2 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ,array( 'type' => 'text' ,'field' => 'custom_h3' ,'label' => 'H3 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ,array( 'type' => 'text' ,'field' => 'custom_h4' ,'label' => 'H4 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ,array( 'type' => 'text' ,'field' => 'custom_h5' ,'label' => 'H5 Size' ,'description' => 'class="regular-text"' ,'help' => 'You can easily add tooltips to your fields with the help parameter.' ,'columns' => 2 ) ) )); -
July 1, 2015 at 2:00 pm #3949
SteveKeymasterThat’s because the field names in the two groups are the same. This is not a Piklist requirement, this is a requirement of standard forms.
Make sure each field name is unique, and it should work fine.
-
July 1, 2015 at 2:32 pm #3950
sancreativeMemberSorry my fault for pasting the previous code in a hurry.
I’ve tried this in a brand new install using the latest version of piklist and the demo’s enabled.
the code i used is a modified version of piklist-demo group tab in settings
please let me know if this works for you?<?php /* Title: Field Groups Setting: piklist_demo_fields Tab: Groups Tab Order: 40 Order: 30 */ piklist('field', array( 'type' => 'group' ,'label' => '1st Address (Un-Grouped)' ,'description' => 'An Un-grouped field. Data is saved as individual meta and is searchable.' ,'fields' => array( array( 'type' => 'text' ,'field' => 'ungrouped_address_1' ,'label' => '1st Street Address' ,'columns' => 12 ) ,array( 'type' => 'text' ,'field' => 'ungrouped_address_2' ,'label' => 'PO Box, Suite, etc.' ,'columns' => 12 ) ) )); piklist('field', array( 'type' => 'group' ,'label' => '2nd Address (Un-Grouped)' ,'description' => 'An Un-grouped field. Data is saved as individual meta and is searchable.' ,'fields' => array( array( 'type' => 'text' ,'field' => 'new_ungrouped_address_1' ,'label' => '2nd Street Address' ,'columns' => 12 ) ,array( 'type' => 'text' ,'field' => '2nd new_ungrouped_address_2' ,'label' => 'PO Box, Suite, etc.' ,'columns' => 12 ) ) )); piklist('shared/code-locater', array( 'location' => __FILE__ ,'type' => 'Meta Box' )); ?> -
July 1, 2015 at 2:34 pm #3951
sancreativeMembersorry another typo correct code below
<?php /* Title: Field Groups Setting: piklist_demo_fields Tab: Groups Tab Order: 40 Order: 30 */ piklist('field', array( 'type' => 'group' ,'label' => '1st Address (Un-Grouped)' ,'description' => 'An Un-grouped field. Data is saved as individual meta and is searchable.' ,'fields' => array( array( 'type' => 'text' ,'field' => 'ungrouped_address_1' ,'label' => '1st Street Address' ,'columns' => 12 ) ,array( 'type' => 'text' ,'field' => 'ungrouped_address_2' ,'label' => 'PO Box, Suite, etc.' ,'columns' => 12 ) ) )); piklist('field', array( 'type' => 'group' ,'label' => '2nd Address (Un-Grouped)' ,'description' => 'An Un-grouped field. Data is saved as individual meta and is searchable.' ,'fields' => array( array( 'type' => 'text' ,'field' => 'new_ungrouped_address_1' ,'label' => '2nd Street Address' ,'columns' => 12 ) ,array( 'type' => 'text' ,'field' => 'new_ungrouped_address_2' ,'label' => '2nd PO Box, Suite, etc.' ,'columns' => 12 ) ) )); piklist('shared/code-locater', array( 'location' => __FILE__ ,'type' => 'Meta Box' )); ?> -
July 1, 2015 at 2:51 pm #3952
SteveKeymasterYup… that’s a bug!
Try this:
$options = get_option('piklist_demo_fields'); echo _('1st Street Address: ') . $options['global_headings_style_group']['ungrouped_address_1'][0] . '
'; echo _('PO Box, Suite, etc.: ') . $options['global_headings_style_group']['ungrouped_address_2'][0]; piklist('field', array( 'type' => 'group' ,'field' => 'global_headings_style_group' ,'label' => '1st Address (Un-Grouped)' ,'description' => 'An Un-grouped field. Data is saved as individual meta and is searchable.' ,'fields' => array( array( 'type' => 'text' ,'field' => 'ungrouped_address_1' ,'label' => '1st Street Address' ,'columns' => 12 ) ,array( 'type' => 'text' ,'field' => 'ungrouped_address_2' ,'label' => 'PO Box, Suite, etc.' ,'columns' => 12 ) ) )); piklist('field', array( 'type' => 'group' ,'field' => 'global_headings_style_group_2' ,'label' => '2nd Address (Un-Grouped)' ,'description' => 'An Un-grouped field. Data is saved as individual meta and is searchable.' ,'fields' => array( array( 'type' => 'text' ,'field' => 'new_ungrouped_address_1' ,'label' => '2nd Street Address' ,'columns' => 12 ) ,array( 'type' => 'text' ,'field' => 'new_ungrouped_address_2' ,'label' => '2nd PO Box, Suite, etc.' ,'columns' => 12 ) ) )); -
July 2, 2015 at 12:41 am #3953
sancreativeMemberThis works:
$options = get_option('piklist_demo_fields'); echo _('1st Street Address: ') . $options['global_headings_style_group']['ungrouped_address_1'][0] . ' '; echo _('PO Box, Suite, etc.: ') . $options['global_headings_style_group']['ungrouped_address_2'][0];Thank you for your help Steve, Much appreciated.
-
July 2, 2015 at 9:24 am #3956
SteveKeymasterYou’re very welcome. Closing ticket.
-
-
AuthorPosts
- The topic ‘How to get value from settings page grouped fields’ is closed to new replies.