proximity2008
Forum Replies Created
-
Hey Michael,
Please post back your findings with the alternate solution. Would be good to share and see if there is an easier way.
Thanks.
Ok try another way.
Make a file and put it into your theme directory.
“cft.js” and link to it using the same technique e.g. in the instructions area of the CFT:<script type="text/javascript" language="javascript" src="/wp-content/yourtheme/cft.js"></script>
Paste the above code into cft.js:
jQuery(document).ready(function() { jQuery('.thumb').hide(); });
If that doesn’t work then you might have a conflict with another plugin. I have seen this happen before, turn off all your plugins and just have the CFT plugin working.
Happy to help.
1. Do you have more than one custom field with the same name in your template?
2. Are you calling the
<?php echo get_post_meta($post->ID, 'nameofyourfield', true); ?>
correctly in your template? I suspect you have a problem with 2.
Further reference:
Get Post MetaIf I ever get around to it on my site I’d post up what I’ve done in the past. I’ve used this plugin for at least 2 years now and learned a lot. Along the way you pick up tricks, and it would be nice to consolidate them for reference. I see the same sorts of problems again and again in this forum.
Hey there,
At the moment this is really buggy. I can only guess what your custom fields look like as you haven’t posted them up.
Here is something I’ve worked on just recently.
[accordion_fieldset] type = fieldset_open class=accordion multiple = true multipleButton = true [accordion_title] type = textfield label = Accodion Title class = text blank = true [accordion_introtext] type = textfield label = Teaser text for the Accordion class = text blank = true [accordion_content] type = textarea hideKey = true label = Content for the Accordion blank = true class = sharedescription [accordion_fieldset] type = fieldset_close
Make sure blank is set to true on your fields. You want the to occupy space in the database so everything lines up. Also the naming convention is ‘accordion_’. This is important because you’ll be using this to to do a like search from the database.
In your functions add this function I’ve written.
/** * Constructs an ordered array from cf metadata * * @param string $like_item set in the CFT plugin based on the repeating fieldset name e.g. "test" would use 'test_fieldset'. * Keep the meta_key unique. * @return array associated array */ function get_cft_repeating_data( $like_item ){ global $post, $wpdb; $sql = "SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID AND meta_key LIKE '%" . $like_item . "%' ORDER BY meta_id ASC"; $data_objects = $wpdb->get_results($sql); $project = array(); $i = 0; $fieldset = $like_item . '_fieldset'; foreach($data_objects as $data) { // the name of the fieldset: if ( $data->meta_key == $fieldset ) { $limit = $data->meta_value; } $i = ( $i <= $limit ) ? $i : 1; if( $data->meta_value != $limit && $data->meta_value !='' ) { $project[$i]["$data->meta_key"] = $data->meta_value; } $i++; } if(!$limit && user_logged_in() ) echo 'Could not establish Custom Field Limit. The $like_item set was ' .$like_item . '<br /> SQL query was ' . $sql; else return $project; }
In your template you can call your function with
$accordion_data = get_cft_repeating_data('accordion'); print_r($accordion_data);
And that should have your custom fields in order.
When I mention this is buggy I mean that I found while entering data into the Custom Field Template sometimes you’d push update and randomily custom fields would be lost. Quite frustrating.
The other thing is that I’ve experienced is that you can’t use TinyMCE on textareas. Although they show up, the ids are all the same when you duplicate them, so when editing the duplicated field only the first field would be affected.
Long rambling post. I hope this helps.
Close:
[thumb] type = text size = 100 label = Thumb output = false class = thumb
And
<script type="text/javascript" language="javascript"> jQuery(document).ready(function() { jQuery('.thumb').hide(); }); </script>
Hey,
Do you know javascript?
You can use the instructions area of the Custom Field Template to write your own javascript.
<script type="text/javascript" language="javascript"> jQuery(document).ready(function() { jQuery('#idofcustomfield').hide(); }); </script>
Hi again,
Sorry should’ve been more clear. The last code submitted is a test. You should put it on a page (page.php) and then load that page in your browser.
The output will help to see where things are not working.
Thanks.
Forum: Plugins
In reply to: [Custom Field Template] [Plugin: Custom Field Template] Javascript ProblemsTurn off all your plugins except the Custom Fields Template. Does the problem persist?
Try this code in a php template.
<?php global $wpdb; $values = array(); $attachments = $wpdb->get_results('SELECT * FROM wp_ngg_gallery'); echo '<pre>'; echo 'query results: ' . print_r($attachments); $wpdb->print_error(); echo '</pre>'; foreach ($attachments as $attachment) { $str = '[ngggallery id=' . $attachment->gid . ']'; $values[] = $str; } echo '<pre>'; echo '$values: ' . print_r($values); echo '</pre>'; ?>
Forum: Plugins
In reply to: [Plugin: Custom Field Template] Repeating custom fieldsThere is one more major caveat to this repeating technique. You can’t use tinymce or html textarea content types.
When you push the “Add New” on the fieldset all the code is duplicated. You do get a new field but TinyMCE and the HTML editor are still tied to the original content area.
So when you use any javascript, it will affect the original textarea not the newly created one.
I’d love a fix for this.
Hi,
You need to output the fields in your php template files.
<?php echo get_post_meta($post->ID, 'nameofyourfield', true); ?>
Also read up on custom fields (the CFT is just a fancy interface for WordPress Custom Fields)
Custom FieldsNo it will work with php4, but I’d move host php 4 is really old!
Yeah I have heard good things with Magic Fields but I’ve stuck with CFT.
A shame that we couldn’t sort this issue out.
Ok,
The code does work, I’ve tested it.
How are you storing your images? In NextGen galleries I hope because this outputs complete galleries.