Forum Replies Created
-
AuthorPosts
-
SteveKeymaster@jason– Ok, we have a few things here.
First I would change your code to the following, which moved the label for your second field to the actual value of the choice:
piklist('field', array( 'type' => 'group', 'field' => 'taxonomies', 'label' => 'Taxonomies', 'add_more'=> true, 'fields' => array( array( 'type' => 'text', 'field' => 'name', 'label' => 'Name', 'required' => true, 'columns' => 12 ), array( 'type' => 'checkbox', 'field' => 'hierarchical', 'required' => true, 'columns' => 12, 'choices' => array( 'true' => 'Hierarchical *' ) ) ) ));Second, we have a new version of Piklist coming out that fixes all the alignment errors.
SteveKeymasterSince it’s only a single level add-more it might be easier to just loop through it the way you originally suggested.
SteveKeymasterWorking with multi-dimensional arrays is never fun, that’s why we made it easy to output data. However, if you want to access the variables and work with them you are going to have to create your own methods.
The array is structure so all the data is in order. All key [1] is related to the same add-more for example.
SteveKeymasterDue to the nature of the Add-mores and how powerful they are, we had to use an unconventional array structure. But don’t worry, Piklist helps you get the data out.
Check out the docs on Add-More’s. It’s explained in detail.
Let us know if you still need help.
SteveKeymaster@egnsh98– Thank you for pointing that out. I updated the Tutorial and hopefully it’s clearer. Scope is one of the most misunderstood parts of Piklst… and also one of the most powerful.
SteveKeymaster@egnsh98– You are on a Settings page, but have set:
scope' => 'taxonomy'Scope does a lot of things, one of them is where you want to save the data. I’m guessing you want to save
sched_groupas a setting not to a taxonomy.In most cases you should never have to set scope. By default you should just leave it out and let Piklist automagically figure out what to do.
SteveKeymaster@civilz– I believe this is not working because you are on a settings page and setting:
'scope' => 'post_meta'.Let Piklist determine the scope automagically:
piklist('field', array( 'type' => 'file' ,'field' => 'logo_upload_file' ,'label' => 'logo upload' ,'description' => 'Size Only : 97 x 338 px' ,'options' => array( 'basic' => true ) ));
SteveKeymaster@jason– Well, you just ruined one of our surprises for the next release. 😉
We will be adding a filter to the comment blocks so you can do exactly what you just asked for.
1) First, you will need to manually add the filter yourself until 0.9.4 is released. Open class-piklist-cpt.php. And find this line:
$types = empty($data['type']) ? get_post_types() : explode(',', $data['type']);
2) Add this code right before that line:
$data = apply_filters('piklist_add_meta_box', $data, $post);
3) Now you can filter the $data array that pulls in the comment block.EXAMPLE:
add_filter('piklist_add_meta_box','my_comment_block_filter', 10, 2); function my_comment_block_filter($data, $post) { // filter $data array here return $data; }Let us know if you have questions on how to use this.
SteveKeymaster@civilz– $count shouldn’t be in quotes, and you don’t have to echo it. You might want to try the format below for query_posts. It is more clear and readable.
One other thing,
$count = $theme_options['count_nabz']is probably an array. You can see this by typingprint_r($count);So the full code should be:
$theme_options = get_option('my_theme_settings'); $count = $theme_options['count_nabz']; $count = $count[0]; $args = array( 'cat' => 2, 'posts_per_page'=> $count ); query_posts( $args );
SteveKeymaster1) Since this is a setting, let’s grab all your settings:
$settings = get_option('my_settings');. Replacemy_settingswith whatever is in the comment block of your settings file.
2) Now let’s find the image ID for the fieldlogo_upload_file:$image_id = $settings['logo_upload_file'];
3) WordPress gave us back an array, but we are only interested in the first key=>value pair:$image_id = $image_id[0];
4) Now that we have the image ID for the attachment, lets use a standard WordPress function to display the associated image:<a href="#"><img class="head-logo" src="<?php echo wp_get_attachment_url($image_id);?>"></a>FULL CODE
$settings = get_option('my_settings'); $image_id = $settings['logo_upload_file']; $image_id = $image_id[0];<a href="#"><img class="head-logo" src="<?php echo wp_get_attachment_url($image_id);?>"></a>Let me know if you still have any issues.
SteveKeymaster@egnsh98– You can use the “field” template to remove the label:
'template' => 'field'.As for the HTML table, please post some code or line drawings.
SteveKeymaster@egnsh98– After looking at your code I think there may be a better way to do it. We suggest using the Piklist Filter
<a href="http://piklist.com/user-guide/docs/piklist_pre_update_option/">piklist_pre_update_option</a>. This filter will allow you to manipulate the data entered into the settings page BEFORE the page is saved.You probably want to do something like this:
add_filter('piklist_pre_update_option','my_update_option',10,3); function my_update_option($settings, $new, $old) { $field_one = $settings['field_one']; $new_field_one = my_function($field_one); if (isset($_REQUEST['autotweet_settings'])) { $settings['field_one'] = 'new_field_one'; } return $settings; }Let me know if that works for you.
-
AuthorPosts