Skip Navigation

[Closed] Further help needed converting from Easy Content Type

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 9 replies, has 2 voices.

Last updated by Shane 3 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#1720569

Following my earlier query I have started the process of converting my Easy Content Types custom post types and fields to Toolset.

So far I can create the new post type, create the customer field group, and assign the custom fields to the group.

After doing this with my first post type I have the following problems:

1) My fields include a date - Easy Content Types stores this as a unix timestamp and this is what is displayed when editing posts. How do I get Toolset to recognise this as a date and display it properly?

2) I have a repeating file field. This is linked back to the Easy Content Types field and Toolset knows that this is a repeating field and will let me add an extra entry, but only the first entry is displayed for existing posts - How do I get Toolset to display all the existing entries for a post?

3) My custom post types also have taxonomies. I can't work out how to migrate them. If I try to add a new taxonomy with the correct slug I get an error because the slug is 'reserved' - How do I get Toolset to recognise the existing custom taxonomies?

Thanks

Dave

#1720905

I have managed to solve number 3 above. It turned out that I had a page using the same slug as the taxonomy. I temporarily renamed the page and was able to create the taxonomy. The existing data then appeared properly and I renamed the page back.

I understand that it's not good practice to have the page and taxonomy using the same slug, but I'm migrating from a site that has been in place for nearly 10 years without any issues so I don't expect it to cause a problem. I think this is because the URL scheme means that the slugs never clash.

I still need help with 1 and 2.

Thanks

Dave

#1721105

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dave,

Thank you for getting in touch.

Given that you've already resolved #3 this leaves us with the 2 below.

1) My fields include a date - Easy Content Types stores this as a unix timestamp and this is what is displayed when editing posts. How do I get Toolset to recognise this as a date and display it properly?

Our Types plugin will only convert our native Dates custom fields to human readable date formats. In order to convert the unix timestamp of another plugin you will need to run it through a custom shortcode in order to get the value and convert it.

You can try this custom shortcode below.

function wp_date_totimestamp( $atts ) {
 
    // Attributes
    $atts = shortcode_atts(
        array(
            'timestamp' => '',
'format'=>'',
        ),
        $atts
    );
 
     $date = date($atts['format'], $atts['timestamp']);
    return $date;
 
}
add_shortcode( 'wp_timestamp_todate', 'wp_timestamp_todate' );

The correct way to use this shortcode is [wp_timestamp_todate timestamp='timestamp shortcode goes here' format='date format goes here']

Add this custom shortcode to your custom code section in Toolset -> Settings -> Custom Code and add it and activate it.

For more information on timestamp formats you can have a look at the link below.
hidden link

2) I have a repeating file field. This is linked back to the Easy Content Types field and Toolset knows that this is a repeating field and will let me add an extra entry, but only the first entry is displayed for existing posts - How do I get Toolset to display all the existing entries for a post?

What is the shortcode that you are using to display this repeatable field on the frontend?

Please let me know.

Thanks,
Shane

#1721195

Hi Shane,

Since my last message I have been doing soem further digging.

For the date issue, I am still confused as to why a custom shortcode is needed. When I look at the database, the database values written by Easy Content Types are as follows:

+---------+---------+-----------+------------+
| meta_id | post_id | meta_key | meta_value |
+---------+---------+-----------+------------+
| 1352 | 640 | ecpt_date | 1272326400 |
| 1383 | 678 | ecpt_date | 1305590400 |
+---------+---------+-----------+------------+

I created a date field in Toolset and the values are as follows:

+---------+---------+---------------+------------+
| meta_id | post_id | meta_key | meta_value |
+---------+---------+---------------+------------+
| 36006 | 13440 | wpcf-testdate | 1594339200 |
+---------+---------+---------------+------------+

Both are writing standard unix timestamps so I don't understand why Toolset won't pick up the value? I do see that the interface won't let me choose the date format (presumably because you're trying to avoid issues where plugins have written dates as text or something else) but is there not a way to force a situation where the data is used as is? For example, can I not overide the interface by manually modifying the configuration of the custom field to be a date in the database (or wherever Toolset is storing it)?

My issue with a custom shortcode is that entries added in the future won't work because Toolset doesn't see the field as a date and so doesn't provide the correct UI. I really need to find a way to have the old and new entries work properly.

I have found that the handling of the repeatable field is going to be more difficult. I was trying to display it using a 'repeating field' block. I have now learned that repeating fields aren't a standard feature and the issue I'm having is because of a different in the way they're handled in Toolset.

I created a new repeating field in Toolset and the data looks like this:

+---------+---------+----------------+--------------------------------------------------------------------+
| meta_id | post_id | meta_key | meta_value |
+---------+---------+----------------+--------------------------------------------------------------------+
| 36005 | 13440 | wpcf-filething | hidden link |
| 36004 | 13440 | wpcf-filething | hidden link |
| 36003 | 13440 | wpcf-filething | hidden link |
+---------+---------+----------------+--------------------------------------------------------------------+

You are writing a separate database entry for each item (and I think there's another entry that controls the sort order)

When I look at one of the Easy Content Types repeating fields it looks like this:

| 34702 | 12781 | ecpt_alternativeformats | a:2:{i:0;s:75:"hidden link";i:1;s:76:"hidden link";}

ECT encodes all the entries in one database row, giving their lengths, and the display order. Annoyingly, the format is a bit like JSON, but isn't JSON so it needs custom decoding.

I suspect that the only way to convert it is to write custom code to read the ECT entries, parse them out, and then add them back as Toolset entries. I am an ok coder, but I'm not really familiar with php or the internals of WordPress so I think it's going to be a bit of a slog.

My thought is that I need php code to pull all the custom posts out, and loop through them reading the ECT custom fields, then writing out Toolset ones. Once that's done, and assuming it works, I can just remove the ECT entries from the database.

I'mve written some WordPress loops before so I'm happy with the reading side of it, but are you able to give me any pointers as to how I can safely write back Toolset compatible entries? are there any exposed functions that I can call?

Thanks,

Dave

|

#1721197

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dave,

That is because the Types custom fields are retrieved using our Types shortcode [types field='my-field'][/types] . Only fields created with Types will be able to use this shortcode.

If the field isn't being retrieved with this shortcode then it will need to be converted by some custom code in order to have the unix timestamp into a readable format.

Thanks,
Shane

#1721209

Shane,

So I may need to sort out the dates using the same process that I outlined for the repeating field. Basically go through and replace all the ECT fields with Toolset ones.

I’m still not sure how I’ll do it. As I said before, is there any Toolset documentation that might help me find the functions that I need?

Dave

#1721499

I have a further question about this. I have been looking at WP Import All and the Toolset Add In.

Can you confirm whether the Toolset Add In supports repeatable fields? I am wondering if I can solve my problem using export/import. i.e.

1) Export the custom fields from my current site
2) Modify the output file to separate the ECT repeating fields into separate entries
3) Import the modified file so the fields are created properly

I am also thinking that I might be able to export/import the date fields.

Dave

#1721839

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dave,

If I know which shortcode you are using to retrieve the fields then I can help better.

As you said you were getting the fields to display, however they were only showing the first results in the list of repeatable fields. Can you let me know how you are displaying the items on the frontend ?

Can you confirm whether the Toolset Add In supports repeatable fields? I am wondering if I can solve my problem using export/import. i.e.

1) Export the custom fields from my current site
2) Modify the output file to separate the ECT repeating fields into separate entries
3) Import the modified file so the fields are created properly

For the repeatable fields I'm not sure as the Toolset Types add-on wasn't built by us for the WP import All plugin. For that you will need to get a confirmation from the WP import team.

However you can try creating a corresponding repeatable field and try to export and then reimport it into the toolset created one.

Thanks,
Shane

#1721849

Hi Shane,

I think I explained before that I am using the 'reputable field' option in the block editor. This works for the inbuilt fields, but not for the ECT ones. I'm fairly sure that this is because of the database field format differences I pointed out.

I will check with the WP Import All team. I had assumed that you folk had been involved in the development even though it isn't your plug in. I don't currently own WP Import All so I have no way of testing it. I want to find out what is possible before I spend the money.

Dave

#1721871

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dave,

Please keep me up to date on this and if we have to work on a slightly custom solution for you I will be more than happy to help given that its just retrieving and converting the field data.

In any case it can be a simple modification of my custom shortcode in my post below which will allow you to retrieve the field data and convert it to human readable format.
https://toolset.com/forums/topic/further-help-needed-converting-from-easy-content-type/#post-1721105

Thanks,
Shane

The topic ‘[Closed] Further help needed converting from Easy Content Type’ is closed to new replies.