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

Creating translations in GridField/ModelAdmin doesn't work #55

Closed
chillu opened this issue Oct 8, 2012 · 11 comments
Closed

Creating translations in GridField/ModelAdmin doesn't work #55

chillu opened this issue Oct 8, 2012 · 11 comments

Comments

@chillu
Copy link
Member

chillu commented Oct 8, 2012

Migrated from http://open.silverstripe.org/ticket/7771

I added a DataObject? and ModelAdmin? with this code:

class Category extends DataObject {
        static $db = array(
                'Title' => 'Varchar(255)'
        );
}

class CategoryAdmin extends ModelAdmin {
        public static $url_segment = 'categories';
        public static $menu_title = 'Categories';
        public static $managed_models = array('Category');
}

and this in the mysite/_config.php:

Object::add_extension('Category', 'Translatable');

I then created a Category and attempted to make a new translation of it, and nothing happened. I didn't see any Javascript errors either.

@joernroeder
Copy link

i have trouble with this issue… any progress on it?

@tscole
Copy link

tscole commented Jul 16, 2013

Is there any solution to this (in particular one that works with 3.0 compatible branch)? It's pretty critical - been open 6 months - and I can't find a fix for it

@gcoderre
Copy link

Bump. If anyone can provide initial guidance, I'll happily work on a fix for 3.1+. @chillu ?

@chillu
Copy link
Member Author

chillu commented Aug 30, 2013

For 2.4 we had a proof of concept module: https://github.com/silverstripe-labs/silverstripe-translatablemodeladmin
That's not using GridField of course. Can you check how far https://github.com/bummzack/translatable-dataobject gets you? Maybe we can take a similar approach?

@axyr
Copy link

axyr commented Dec 13, 2014

I think I managed to get it working with a few changes. I would like to discuss this before I setup a pull request.

  1. The js file triggers .LeftAndMain :input[name=action_createtranslation] which is not present in the ItemEditForm of ModelAdmin (missing .LeftAndMain).
  2. The method createtranslation is not callable from GridFieldDetailForm_ItemRequest.
  3. TranslatableCMSMainExtension requires a $this->owner->stat('tree_class').
  4. Translatable::updateCMSFields() requires a method CMSEditLink() on the DataObject.

In this Paste I more got the Translations working for a DO, but Im not quite sure if we should create a custom TranslatableModelAdmin, or change TranslatableCMSMainExtension and Translatable.
I did not have tested it yet very extensively, but at first glance all seems fine, and there might be some improvements possible

http://www.sspaste.com/paste/show/548c8f48d5988

@coobersdoobers
Copy link

@axyr Your solution is working, but if your item, selected from GridView has also GridView, items within have the same problem. Do you know a solution?

@coobersdoobers
Copy link

@chillu Have you found working solution?

@sanderha
Copy link

@axyr Your solution works to a certain extend. However, I try to manage Pages in modeladmin. When using your solution, it creates a translation of the page in the SiteTree_Live table, and not in the SiteTree table.
Any ideas?

EDIT: Setting Versioned::reading_stage('Stage'); in the ModelAdmins init() method will solve my particular issue

@andy2708
Copy link

andy2708 commented Aug 20, 2016

I can't seem to get your solution working @axyr.
Has there been a proper fix implemented for this yet?

I never see anything to do with translation in the model admin and adding anything debug related to TestObjectAdminDetailForm_ItemRequest methods dont show up as if it never gets hit.
Any help?

EDIT:
I had to add the TestObject::add_extension("translatable") to my _config.php to fix that issue.

@camelscript
Copy link

camelscript commented Feb 21, 2017

Still cant figure this out. At start there was no button when I added the code from axyr, the button apperared. Now the button works, but when i create translation the list under "Existing translations" is empty.
I debugged so far that i found out that the bug arises at translatable/code/model/Translatable.php:1117
Where method
$existingTranslation->hasMethod('CMSEditLink')
returns false, though $existingTranslation has linked translation. That is possibly because i am trying to translate dataobject which i believe don't have CMSEditLink() method.
Conclusion: needs functionality that generates edit link.

@maxime-rainville
Copy link

Unfortunately, SilverStripe 3 has entered limited support in June 2018. This means we'll only be fixing critical bugs and security issues for SilverStripe 3 going forward.

You can read the SilverStripe Roadmap for more information on our support commitments.

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

No branches or pull requests