Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Craft 3? #12

Open
bossanova808 opened this issue May 29, 2018 · 3 comments
Open

Craft 3? #12

bossanova808 opened this issue May 29, 2018 · 3 comments

Comments

@bossanova808
Copy link

I presume given native focal points you're not planning on porting this one?

I don't suppose there is any migration stuff for taking existing set focal point data and translating that to C3?

@achord
Copy link

achord commented Nov 24, 2018

Great plugin. Craft 3 is much needed

@bossanova808
Copy link
Author

Just a note for any googlers - I wrote a really quick and nasty hack to port old focalpoint field values to the new in built asset focalpoint thing...seems to work!

        $result = $mysqli->query("SELECT elementId, title, field_focalPoint FROM craft_content WHERE field_focalPoint IS NOT NULL AND NOT field_focalPoint = '50% 50%';
");

        while($row = $result->fetch_object()){

            $splitValues =   explode(" ", str_replace("%","", $row->field_focalPoint));
            $newValue = $splitValues[0]/100 . ';' .  $splitValues[1]/100;

            print ("Element id $row->elementId : $row->field_focalPoint translates to $newValue\n");

            $count = $db->createCommand()->update('{{%assets}}', [
                'focalPoint' => $newValue,
            ], ['id' => $row->elementId])->execute();

            print("$count rows affected\n");

        }

@jamesmacwhite
Copy link

@bossanova808 Thanks for this, I was able to migrate existing Craft 2 focal point field data to Craft 3. This is a good candidate for a content migration, which I wrote based on your original code here:

https://gist.github.com/jamesmacwhite/9534eee36a62756722f6728a9209e83e

Hope it helps others!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants