Jump to:

7937 Posts in 1537 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » [ImageGallery] Translatable Problems

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3 4 5
Go to End
Author Topic: 6608 Views
  • Xeal
    Avatar
    Community Member
    37 Posts

    Re: [ImageGallery] Translatable Problems Link to this post

    Hey thanks a lot for this! Really appreciated I'll try and see if I can't fix some of it with my limited php skills haha.. Either way it's a step in the right direction and at least for now there seems to be a way of fixing it, so hopefully we can figure it all out and get the translations working with the modules =)

  • wmk
    Avatar
    Community Member
    45 Posts

    Re: [ImageGallery] Translatable Problems Link to this post

    Hi xeal,

    did some research on this but didn't come so far. have to stop now and want to share my results.

    i tried to join the translation table but somehow an automagical "AND ImageGalleryPageID = ..." is added. Removing this manually and running the query in phpMyAdmin gets me the wanted results.
    TableListField seems to add the additional where clause

    Here is my (not yet working) code:

    $translationGroupID = $this->getTranslationGroup();
    $baseDataClass = ClassInfo::baseDataClass($this->class);
    $join = sprintf('LEFT JOIN `%s_translationgroups` tg ON `tg`.`TranslationGroupID` = %d',
    $baseDataClass,
    $translationGroupID
    );
    $albumFilter = $this->albumClass . '.ImageGalleryPageID = tg.OriginalID';

             $manager = new DataObjectManager(
                $this,
                'Albums',
                $this->albumClass,
                array('AlbumName' => _t('ImageGalleryAlbum.ALBUMNAME','Album Name'), 'Description' => _t('ImageGalleryAlbum.DESCRIPTION','Description')),
                'getCMSFields_forPopup',
                $albumFilter,
    null,
    $join
             );

    Reading in docs http://doc.silverstripe.com/doku.php?id=tablelistfield&s=customquery i think either $customQuery or maybe http://doc.silverstripe.com/doku.php?id=tablelistfield&s=customquery#source_input setCustomSourceItems() could be our friend. See LanguageSwitcherWidget how it retrieves the DataSet.

    I'd go with customquery, which of course has to be included in Controller for frontend output, too.

    hth for now

    wmk

  • Xeal
    Avatar
    Community Member
    37 Posts

    Re: [ImageGallery] Translatable Problems Link to this post

    Hi wmk,

    Thanks for the information it helped me work out a few things.

    As of right now I can get all the albums in both the English and French translation.
    The only problem is right now in the French version it sees the albums in the albums tab, but as soon as I switch to the photos tab it asks me to create an album to add photos. I'll post the code I have so far which is working, but as I explained not fully.

             $translationGroupID = $this->getTranslationGroup();
             $baseDataClass = ClassInfo::baseDataClass($this->class);
             
             $resultSet = new DataObjectSet();
             $filter = $this->albumClass . '.ImageGalleryPageID = tg.OriginalID';
             $sort = "";
             $join = sprintf('LEFT JOIN %s_translationgroups tg ON tg.TranslationGroupID = %d',
                $baseDataClass,
                $translationGroupID
             );
             $instance = singleton($this->albumClass);      
             $query = $instance->buildSQL($filter, $sort, null, $join);
             
             $manager = new DataObjectManager (
                $this,
                'Albums',
                $this->albumClass,
                array(
                   'AlbumName' => _t('ImageGalleryAlbum.ALBUMNAME','Album Name'),
                   'Description' => _t('ImageGalleryAlbum.DESCRIPTION','Description')
                ),
                'getCMSFields_forPopup',
                "ImageGalleryPageID = {$this->ID}"
             );
          
             $manager->setCustomQuery($query);

    I'm about to stop for the day and I figured I'd post what I found as you did, so anyone who wants to pick this up can be up to date with our changes.

    Xeal

  • banal
    Avatar
    Community Member
    901 Posts

    Re: [ImageGallery] Translatable Problems Link to this post

    Sorry for digging up an old post.
    I'd just like to thank wmk for the patch he provided to make the DOM work with translatable.

    Seems like the translatable extension doesn't receive much attention from module developers (I admit, it's a rather complex subject).

    I can understand the frustration of the OP perfectly, I too was frustrated when I built a site with UserForms and DOM and then the whole thing stopped working when translations were enabled. At least the DOM works, now I just need to find a solution to the userforms problem. I guess I'll end up building a static form...

  • Patrik at Shiki Media
    Avatar
    Community Member
    4 Posts

    Re: [ImageGallery] Translatable Problems Link to this post

    Hi!

    Any news on this? I´m having the exact same problem as Edu115! My clients project is also halted due to this issue..

  • UncleCheese
    Avatar
    4085 Posts

    Re: [ImageGallery] Translatable Problems Link to this post

    Banal seems to think that wmk submitted a working patch. Is that true?

  • Patrik at Shiki Media
    Avatar
    Community Member
    4 Posts

    Re: [ImageGallery] Translatable Problems Link to this post

    Yeah, but didn´t he write that it wasn´t working yet. I´m not a programmer and would need a working code to use!

  • banal
    Avatar
    Community Member
    901 Posts

    Re: [ImageGallery] Translatable Problems Link to this post

    I successfully patched the DataObjectManager to work with Translatable. I don't think that it will work with the ImageGallery Module though.
    Actually it is a set of patches that have to be applied. Some of them are provided by the SilverStripe devs (patches to ComplexTableField) and then on top of that, one has to apply the DOM patch by wmk.

    I'm assuming that the ComplexTableField patches are in SilverStripe trunk, so getting the code from there should work. Then the only thing that needs to be patched is the DataObjectManager, unless UncleCheese has merged the wmk patch back into his code?

    6608 Views
Page: 1 2 3 4 5
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.