mplodowski / seomanager-plugin-public

https://octobercms.com/plugin/renatio-seomanager
https://octobercms.com/plugin/renatio-seomanager
4 stars 1 forks source link

Model translation #13

Closed adamo closed 3 years ago

adamo commented 4 years ago

I've implemented the seo tag manager with the

public $implement = ['@RainLab.Translate.Behaviors.TranslatableModel','@Renatio.SeoManager.Behaviors.SeoModel',];

    public $translatable = [
        'name',
        'description',
        'subtitle',
        'seo_tag[meta_title]',
        'seo_tag[meta_description]'
    ];

But cant save the seo field for other languages (error Call to a member function hasRelation() on array)

impactfactory commented 3 years ago

If I add the translatable fields in Model class like this

'seo_tag[og_description]', 'seo_tag[og_image]', 'seo_tag[og_title]', 'seo_tag[meta_description]', 'seo_tag[meta_keywords]', 'seo_tag[meta_title]',

And try to save my entries in the backend update view, following error comes up:

"Call to a member function hasRelation() on array" on line 70 of /Users/HeartSwami/Sites/dth/modules/backend/Traits/FormModelSaver.php

Would be very helpful if the seo fields can be translatable too in our own plugins!!

vshepel commented 3 years ago

Up!

mplodowski commented 3 years ago

It took me some time, but this feature is finally available with version 3.0.0. This version only supports OctoberCMS 2.x, so please upgrade your October installation before upgrading SeoManager plugin.

OctoberCMS and RainLab.Translate does not fully support polymorphic relation for models.

To solve this problem and make integration with other models available you must add columns to model database table. There is new console command that will scan for all models that implement SeoModel behavior and migrate database tables to add required columns.

php artisan seo:migrate-tables

There is also new command that will migrate old data from renatio_seomanager_seo_tags to models that implement SeoModel behavior.

php artisan seo:patch 3.0
impactfactory commented 3 years ago

Thanx for the work. Im on Winter CMS now and I made my own Blog Plugin to solve that issue in a simple way.