statikbe / craft-ctafield

Fieldtype that combines custom links, entries & classes
MIT License
0 stars 1 forks source link

Craft 5 support #11

Open danethomas opened 2 months ago

danethomas commented 2 months ago

Craft 5 now supports a new Link field type https://github.com/craftcms/cms/discussions/9062 so support for this may no longer be required however before we migrate to that I was wondering if you've had a look at just adding Craft 5 to help with upgrading.

I tried to just change the craft/cms requirement but after the upgrade there seems to be a namespace issue:

{"errorMessage":"Unable to find component class 'statikbe\\cta\\fields\\CTAField'.","expectedType":"statikbe\\cta\\fields\\CTAField"

Any help would be appreicated

janhenckens commented 2 months ago

Hey @danethomas, we've internally switched to using Hyper somwhere around Craft 4.7 and will not be porting this plugin to Craft 5.

We do however have a migration to Hyper (since we also have a bunch of sites on this plugin that will eventually need to be upgraded to 5) that's almost ready for release - which you can find here https://github.com/statikbe/craft-ctafield/tree/feature/hyper-migration

danethomas commented 2 months ago

Excellent news!

I've tried that migration and both completed successfully but when viewing the content for one of the new Hyper fields I'm getting the following error.

Unable to render field - Undefined array key "CTA styles" /**/craft/vendor/statikbe/craft-config-values/src/fields/ConfigValuesFieldField.php:116

From what I can see all the older CTA fields are now Hyper ones but something hasn't gone right for the content migration. We're using Matrix & Neo fields rather than SuperTable. I can see that Matrix fields are supported in the migration, is the issue related to the Neo fields?

danethomas commented 2 months ago

And we've got a new field

Screenshot 2024-09-18 at 10 58 33 AM
janhenckens commented 2 months ago

In the "previous" plugin there was a button style option and we tried to add that to the new Hyper field. But I see I assumed that would always be done with https://github.com/statikbe/craft-config-values, which you might not have installed or configured.

Could you have a go at following the docs for that plugin and create a "CTA Styles" option here to see if that works?

danethomas commented 2 months ago

Craft Config Value is installed but it wasn't clear how to configure it. The usage section in the readme is empty https://github.com/statikbe/craft-config-values/blob/develop/README.md

That said, I've added the following to craft/config/config-values-field.php an things appears to be displaying now.

<?php

return [
    'data' => ['CTA styles']
];
danethomas commented 2 months ago

Is linkClasses only needed if we're using the older button style option. We were using that sporadically, but would prefer to remove it anyway, so just wondering if we should remove that first and then migrate.

Is Craft Config Values only required to support that? Also, is it needed, post migration?

Appreciate the help.

janhenckens commented 2 months ago

Yeah, that's what its there for - but I'm not sure if the migration takes the usage or non-usage of the styles into account.

That's all the Config Values fields is used for yeah, so we might have to make all that optional.

Not sure when we'll be able to get to this though...

danethomas commented 2 months ago

No problem at all - this has been hugely helpful.

We'll remove the classes and I'll try and do a migration without Config Values but I'm fairly sure we'll be good from here.

janhenckens commented 2 months ago

Ok, let us know how you get on! Happy to update some code if you need this for multiple projects :)

danethomas commented 1 month ago

Just an update - we're no longer blocked here.

There were checks to ensure config values was installed as part of the migration. For us - and potentially for others - we didn't really need support for the classes migration or they could have been moved directly into the classes attribute within the Hyper fieldgroup.

Thanks again - this was super helpful and the general migration of fieldtypes and content all worked great.

janhenckens commented 1 month ago

Good to know the content migration works, we've only tested it on one smaller site and have yet to release the feature.