Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
Tagged: 8.38.1, code snippet, csv import, custom field, extension
- This topic has 5 replies, 2 voices, and was last updated 4 years, 6 months ago by
Steven Zahm.
-
AuthorPosts
-
03/07/2019 at 7:05 am #486396
Roland Stumpp
ParticipantHi Steven,
meanwhile we have all the custom fields and boxes inside. Your documentation is very good!
But one question is still open. Inside connections is the the class.geo.php. We would like to use the function “Find the closest locations”
Are we have to buy a additional plugin?
How is the way to use it?
and by the way… we are using connections-tile-plus
our override is in the card.php from the plugin.
Is it possible to have the card.php in the child area?Regards
Roland03/07/2019 at 11:14 am #486421Roland Stumpp
ParticipantHi Steven,
it is possible to import and export a custom field. We include this for a custom field:
But what we have to include in the import and export a custom checkbox and a custom checkbox group too?
Do you have the code snippet for us please
Regards
Roland
-
This reply was modified 4 years, 6 months ago by
Roland Stumpp.
-
This reply was modified 4 years, 6 months ago by
Roland Stumpp.
03/07/2019 at 11:29 am #486427Steven Zahm
Keymaster@ Roland
Looks like I replied to most of these questions in another thread you posted to… here’s the link to my reply
RE: it is possible to import and export a custom field.
Yes, it is, here’ the link to the docs which voer how to do this with a text field.
RE: what we have to include in the import and export a custom checkbox and a custom checkbox group too?
I suggest setting them up for the export first and then export the directory. You’ll see in the export how you need to supply the data for the import.
RE: Do you have the code snippet for us please
There is a code snippet for the text field, you should be able to use it for the other fields too. The important bit is how you structure the data in the CSV file so it imports.
I’m actually revising the code snippet later today with some minor improvements.
Hope this helps!
03/10/2019 at 12:42 pm #486580Roland Stumpp
ParticipantHi Steven,
this is our snippet for the im- and export from our custom fields.
the first one for the export and the second for the import.
The field herden_name is a text field.
The fields genussfleisch,biologisch and herdbuch_zuechter is a checkbox. The last one rinder_farbe is a checkboxgroup. Are the snippets ok?Regards
Rolandadd_filter( 'cn_csv_export_fields', 'cn_register_text_field_header' );
add_filter( ‘cn_csv_export_fields_config’, ‘cn_register_text_field_config’ );
function cn_register_text_field_header( $fields ) {
$fields['herden_name'] = 'Herdenname'; $fields['genussfleisch'] = 'Genussfleischpartner'; $fields['biologisch'] = 'Biobetrieb'; $fields['herdbuch_zuechter'] = 'Herdbuchzucht'; $fields['rinder_farbe'] = 'Farbschlag'; return $fields;
}
function cn_register_text_field_config( $fields ) {
$fields[] = array( 'field' => 'herden_name', 'type' => 5, 'fields' => '', 'table' => CN_ENTRY_TABLE_META, 'types' => NULL, ); $fields[] = array( 'field' => 'genussfleisch', 'type' => 5, 'fields' => '', 'table' => CN_ENTRY_TABLE_META, 'types' => NULL, ); $fields[] = array( 'field' => 'biologisch', 'type' => 5, 'fields' => '', 'table' => CN_ENTRY_TABLE_META, 'types' => NULL, ); $fields[] = array( 'field' => 'herdbuch_zuechter', 'type' => 5, 'fields' => '', 'table' => CN_ENTRY_TABLE_META, 'types' => NULL, ); $fields[] = array( 'field' => 'rinder_farbe', 'type' => 5, 'fields' => '', 'table' => CN_ENTRY_TABLE_META, 'types' => NULL, ); return $fields;
}
add_filter( ‘cncsv_map_import_fields’, ‘cncsv_header_name’ );
add_action( ‘cncsv_import_fields’, ‘cncsv_process_import’, 10, 3 );function cncsv_header_name( $fields ) {
$fields['herden_name'] = 'Herdenname'; $fields['genussfleisch'] = 'Genussfleischpartner'; $fields['biologisch'] = 'Biobetrieb'; $fields['herdbuch_zuechter'] = 'Herdbuchzucht'; $fields['rinder_farbe'] = 'Farbschlag'; return $fields;
}
function cncsv_process_import( $id, $row, $entry ) {
$data = $entry->arrayPull( $row, 'herden_name', '' ); $data = cnFormatting::maybeJSONdecode( stripslashes( $data ) ); $data = $entry->arrayPull( $row, 'genussfleisch', '' ); $data = cnFormatting::maybeJSONdecode( stripslashes( $data ) ); $data = $entry->arrayPull( $row, 'biologisch', '' ); $data = cnFormatting::maybeJSONdecode( stripslashes( $data ) ); $data = $entry->arrayPull( $row, 'herdbuch_zuechter', '' ); $data = cnFormatting::maybeJSONdecode( stripslashes( $data ) ); $data = $entry->arrayPull( $row, 'rinder_farbe', '' ); $data = cnFormatting::maybeJSONdecode( stripslashes( $data ) ); cnEntry_Action::meta( 'update', $id, array( array( 'key' => 'herden_name', 'value' => $data ), ) ); cnEntry_Action::meta( 'update', $id, array( array( 'key' => 'genussfleisch', 'value' => $data ), ) ); cnEntry_Action::meta( 'update', $id, array( array( 'key' => 'biologisch', 'value' => $data ), ) ); cnEntry_Action::meta( 'update', $id, array( array( 'key' => 'herdbuch_zuechter', 'value' => $data ), ) ); cnEntry_Action::meta( 'update', $id, array( array( 'key' => 'rinder_farbe', 'value' => $data ), ) );
}
03/11/2019 at 10:06 am #486619Roland Stumpp
ParticipantAnd here our last question!
How to show only one category in a site. Is there a shortcode with the id from the category?
Regards03/11/2019 at 11:03 am #486630Steven Zahm
Keymaster@ Roland
RE: Are the snippets ok?
Glancing over the code, the snippets look alright… the proof will be in the pudding, so to speak. Do an one row import and followed by an export. If the data imported/exported then you know the snippets are good to go.
Only one suggestion though. I did update the import snippet example on Friday (maybe Thursday). So, you may want to review and update your snippet accordingly:
RE: How to show only one category in a site. Is there a shortcode with the id from the category?
If I understand the question correctly, then yes, here’s the doc link:
Hope this helps!
-
This reply was modified 4 years, 6 months ago by
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.