1

I have a site with multiple locales. I have some entries that will have some basic fields such as title, description, etc and also an asset field. The asset field is translatable so I could have an English PDF and a French PDF for the entry. We often copy over entries and I have noticed when we do it will copy over the English asset but not the French asset. Often times some admins are not aware they have to go back and re-add the French asset which is causing issues.

I am wondering if this is by design, a bug or ideally is there any setting or workaround I could do to fix the issue.

I am doing this in the admin panel when editing an entry and clicking on the arrow on save and selecting save as new entry.

Thanks

1

Im hesitant to say that this is by design because iam not entirely sure what you mean. Instead i'll explain something i think is comparible that happend to us. We have an entry channel with entries which act as the companies of users on the website. When we saved a company profile in Dutch, fields such as the description or company info would not pull across. We fixed this by listening to the onSaveEntry event and simply pulling the fields across manually. This isnt a very pretty or portable way to do it - but this was an incredibly case and website specific feature - we only wanted entries in this website and even just in this section to have this 'copying' feature. From memory the script looked something like the below:

One word of advise i would issue if of advice i would give is if you are working with other content editors is to listen to the cp.entries.edit.right-pane hook and build a small interface that allows them to select the locale and copy over the current locale to the new locale. The script below has one downside which is that it essentially sterilizes the localization function for craft for the affected entries - which in this projects case was crucial - but in yours probably isnt.

Let me know if anything is unclear. One word of notice - if you are working with a relations field which is what a pdf should be. Relations should be copied over IF you are using something like 'Save as a new entry'. If this isnt happening you've probably found a bug.

craft()->on('entries.saveEntry', function(Event $event) {
        $entry = $event->params['entry'];

        // Does the entry section equal our companies section channel? 
        if (craft()->isLocalized() && $entry->sectionId == 2) {

                // What locales are there? 
                foreach (craft()->i18n->getSiteLocales() as $locale)
                {
                    // Is this a foreign locale
                    if ($locale != $entry->locale)
                    {
                        // Get an entry that belongs to this with a sep locale, setup a model and save it. 
                        $otherLocaleEntry = craft()->elements->getElementById($entry->id, ElementType::Entry, $locale->__toString());
                        if ($otherLocaleEntry)
                        {
                            $otherLocaleEntry->getContent()->myFieldsStuff = $entry->getContent()->myFieldsStuff;


                            craft()->entries->saveEntry($otherLocaleEntry);
                        }
                    }
                }
            }
        }
    });
  • Thanks for the info. I am working with relations field and it will copy over the relation for English but does not copy over for any other locale. I will see if I can use onSaveEntry hook to see if I can catch what we need. – Chris Mar 23 '18 at 13:43
  • @chris Alright cool, goodluck. If you need any help with modifying the above your welcome to contact me. One word i will say is that you might want to go to the craft cp, go to settings and go to the fields manager. Click the field you are describing - and check if the setting 'This field is translatable' is set to on. If it isnt its probably worth testing if this is a solution to your problem – Gįëł Tėttëłæår Mar 23 '18 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.