problem with multilingual fields with type template

edited August 2015 in Bug Reports
hello
I have a multilingual site in 2 languages, pages that are created in the CMS used repeatable fields with type template:
'sections' => array( 'type' => 'template', 'display_label' => FALSE, 'label' => 'Sections', 'add_extra' => FALSE, 'repeatable' => TRUE, 'title_field' => 'block', 'fields' => array( 'section' => array('type' => 'section', 'value' => 'Block <span class="num">{num}</span>'), 'block' => array('type' => 'block', 'label' => 'Block', 'group' => 'landing'), ), ),
Suppose I have a page on the Ukrainian language, and I have to do the same in German, for this I choose the German language and add information, when I save this page it exists in two versions, however, in CMS content of this page displayed only Ukrainian in the fields template ...
That is: the content changes when you change the language on the site but in CMS when I change language, I see only Ukrainian content, and if I make corrections on this page after save in the German version of the page all text in a template fields becomes Ukrainian ...

Comments

  • edited 4:28PM
    This appears to be a bug. I've implemented a fix in the develop branch which will have the next round of updates:
    https://github.com/daylightstudio/FUEL-CMS/commit/3027b34d96ae4b6207bcf69fad544c55831d3499
  • edited 4:28PM
    Thanks, it worked!

    I noticed another bug related to the multilingual:
    Let's say I create a page on the Ukrainian language, after saving I choose German language and add content in German, everything works as it should, but when I come out of the edit page and then choose to edit this page again, the value of the language field is one that was the last when the page was saved (ie German) but the content of the page is Ukrainian ...
    To work correctly, I need to change the language in the Ukrainian, otherwise all the corrections will be written in the German version ...
  • edited 4:28PM
    Could you confirm that the "selected" value on the option is set correctly? This seems to be something the browser is doing with remembering your last selection. I've pushed a small change to better help indicate what language you are in above where you edit the pages in the develop branch.
  • edited 4:28PM
    Can I get a reference to that change?
    I do not think that this is connected with a browser, I tried to clear history and temporary files - did not help, even tried to go to the CMS from another computer - if the page has been saved in the German language, the selected language is German, and the entire contents - Ukrainian (default language) ...
  • edited 4:28PM
    So the situation I was seeing was that I would change language, hit save, then hit the back button, and it would still select the language that I was just at. However, in doing an inspection on the element, the "selected" property wasn't set on it for some strange reason I can only contribute to the browser trying to remember the last selection state and if I clicked refresh on that page, it would properly select. Is that what you are seeing?

    The change made was just another inidicator in case the dropdown select is remembering the last item you selected instead of what is actually selected.
    https://github.com/daylightstudio/FUEL-CMS/commit/fda5365e2fc898968d7c705b81a8c5fadd5a6571
  • edited 4:28PM
    Interesting behavior:
    I'm creating a page in the Ukrainian language and save it, then choose German language, add content, save - all goes well ...
    I go to the fuel/pages - choose this page and see the following:
    The language chosen - German
    Content - Ukrainian
    Content in the fields with the type template - German!

    If I choose Ukrainian language - content in all fields becomes Ukrainian, switch to German - all content becomes German - everything is working properly!

    It seems that CMS will remember the last language in which a page was edited and automatically selects it to generate a page for editing in CMS...
    I think that browser is nothing to do with it, I went to the CMS from different computers, even those who had previously not been in CMS - behavior all the same...

    Maybe it has something to do with language_mode, in my config selected 'segment', in the CMS - 'query_string'...

    p.s.
    when I added these changes - fda5365e2fc898968d7c705b81a8c5fadd5a6571
    it did not change the behavior, but added error:

    Message: Undefined offset: 0 Filename: pages / page_create_edit.php Line Number: 58

    swears - <?=$languages[$language]?>
    If switching language - error disappears
    if leave editing page and go back again to edit - the error appears ...

    p.p.s
    file fuel/modules/fuel/views/pages/page_create_edit.php line 56 has extra colon.
  • edited 4:28PM
    I also noticed when in file fuel/modules/fuel/controllers/module.php on line 201 indicate 'default' => 'uk', then in CMS fuel/pages will be display only those pages that were last saved with the language 'uk' and pages that were saved with language 'de' are hidden...
  • edited 4:28PM
    I noticed the Undefined offset error yesterday and posted a fix.
    https://github.com/daylightstudio/FUEL-CMS/commit/1a2da448437c1c1d8f6cc48a5a4162da520dc18a

    If you inspect the language select element in your browser, is the "selected" property set on that particular option? I'm unfortunately not able to quite replicate your issue at the moment. I check the PageController.js file to see if there may be anything suspicious in there to auto select that field with javascript and didn't see anything.

    Also, I'm not quite sure I understand the last comment about line 201... this shouldn't come into play with the pages module because there is no "language" field on the fuel_pages table (more for other modules like navigation and blocks).
  • edited 4:28PM
    I've inspected the language select element:
    If page was saved in German language - "de" will be selected, if Ukrainian - "uk" selected

    about line 201:
    Yeah, I was surprised too, I had to do so that when I opened simple module in CMS, such as news, I only can see the news on the Ukrainian language, and had the ability to filter them by language, however, when in database table add a field "language", CMS adds filter automatically, when I added a filter like this:
    .... 'filters' => array( 'language' => array( 'default' => 'uk', 'label' => 'lang', 'type' => 'select', 'options' => array( 'uk' => 'Українською', 'de' => 'Deutsch' ), ), ),
    it added another filter, which does not work properly...
    so I decided to make changes to the CMS so that the Ukrainian language has been selected by default, and it worked, but pages in the CMS started behaving strangely:
    When I go to the fuel/pages I see a notification - Filters:lang:="uk", and pages that have been stored in the German language in this list does not appear, but if in the Advanced Search choose the language "de", I see pages that were saved in German language for the last time...
    If I choose to edit a page, simply change the "Language" on "uk", and hit save - this page appears in the list of pages in Ukrainian.

    FUEL_VERSION - 1.3
  • edited 4:28PM
    To overwrite the filter try using 'language_equal' instead of 'language' for the filter array key. The reason why it's filtering automatically is because you need to add a 'first_option' => 'Select a language' to the language filter which has an empty value.
  • edited 4:28PM
    Thank you, but if I write like this:
    'filters' => array( 'language' => array( 'default' => 'uk', 'first_option' => 'Select lang...', 'label' => 'Lang:', 'type' => 'select', 'options' => array( 'uk' => 'Українською', 'de' => 'Deutsch' ), ), ),
    That will add an additional filter by language, and by default will check records on "uk" language
    if type this:
    'filters' => array( 'language_equal' => array( 'default' => 'uk', 'first_option' => 'Select lang...', 'label' => 'Lang:', 'type' => 'select', 'options' => array( 'uk' => 'Українською', 'de' => 'Deutsch' ), ), ),
    Nothing happens, the filter is not added or overwritten the current, created by CMS automatically ...
  • edited 4:28PM
    If you change line 199 (as of 1.3 release) in the fuel/modules/fuel/controllers/module.php to the following, does it work:
    if (( ! empty($languages) AND (is_string($first_option) OR (is_array($first_option)) AND count($first_option) > 1)) AND empty($this->filters[$this->language_col.'_equal']))
  • edited 4:28PM
    Yes, thank you, this helped!
  • edited 4:28PM
    Hi, I was able to solve the problem with languages, when the page is stored in the table fuel_pages it saves value of the selected language, I've added in /fuel/modules/fuel/models/fuel_pages_model.php in method on_before_save() some extra code:
    $values['language'] = $this->fuel->language->default_option();
    Now when I save page, regardless of the selected language, the database is always stored the default language, in my case 'uk', and when I need to edit this page I always get the field in terms of 'uk', I understand that the solution is not quite 'right' but it helped get rid of the bug and decided my problem ...
    I think the problem cut out in fuel_page_variables, for some strange reason, CMS does not always choose all the required language page variables, at least in my case.
    Have a nice day!
  • edited 4:28PM
    Hi,
    I just had the same issue, with latest dev version. It looks like the fix (https://github.com/daylightstudio/FUEL-CMS/commit/3027b34d96ae4b6207bcf69fad544c55831d3499) is not in the latest commit. I put it in my file and works
  • edited 4:28PM
    Sorry, but I'm not quite I understand sure which fix you are referring to. Can you clarify?
  • edited 4:28PM
    The fix: https://github.com/daylightstudio/FUEL-CMS/commit/3027b34d96ae4b6207bcf69fad544c55831d3499
    Sorry, I found it in the feature/1.4_dev.
    I'm using the develop branch and the fix is not there.
Sign In or Register to comment.