Be sure to checkout our newest add-on Reading Time Pro!

Compatibility updates:

  • Publisher is EE5 compatible, but it does not currently support the Fluid field (it's in the works).

Ticket: publisher_lang_id does not work properly

Status Resolved
Add-on / Version Publisher 2.10.7
Severity
EE Version 5.1.2

Jules van Schaijik

Feb 06, 2019

I have a front end page with one column displaying the english text of an entry as it is stored in the database, and another column with correlating form fields in which the visitor can make changes. The trouble is that the form fields display the dutch instead of the english text, even though I tell it to do otherwise.

Details: I have a content template (Translations/_bb_speakers_layout) from which I pass the currently saved english text to a layout template:

{layout="Translations/_bb_speakers_layout"}
{exp:channel:entries channel="speakers" url_title="anthony-towey" limit="1" publisher_status="open" publisher_lang_id="1" }
{layout:set name='title'}{title}{/layout:set}
{layout:set name='full_name'}{full_name}{/layout:set}
{layout:set name='position'}{position}{/layout:set}
{layout:set name='talk_title'}{talk_title}{/layout:set}
{layout:set name='talk_abstract'}{talk_abstract}{/layout:set}
{layout:set name='body'}{body}{/layout:set}
{/exp:channel:entries}

Then, on the _bb_speakers_layout template I use the exp:channel:form tag to display the correlated form fields. Here is the opening tag with parameters:

{exp:channel:form
channel="speakers"
url_title="anthony-towey"
return="Translations/speakers/URL_TITLE"
rte_selector=".rich_text_field"
rte_toolset_id="1"
publisher_status="open"
publisher_lang_id="1"
}

The problem is that even though the publisher_lang_id parameter is set to “1” on both the channel:entries and the channel:form tag, get language 1 (english) only on the former, and language 2 (dutch) on the latter.

I’ve attached an image of part of the page to show what I mean

#1

BoldMinded (Brian)

Feb 07, 2019

Hi, Jules. What happens if you don’t use the layout variables and just put everything into the same template file? Can you share the entire exp:channel:form tag (remove all excess html used for layout purposes, just share the basic form fields and EE template code please).

#2

Jules van Schaijik

Feb 07, 2019

Hi Brian,

I’ve put everything into the same template file and gotten rid of most html tags.

The result is still the same. In spite of the publisher_lang_id parameter I get English (language 1) from the exp:channel:entries tag but Dutch (language 2) from the exp:channel:form.

Here’s the entire template:

{layout=“layouts/_outer_wrap_unprotected”}

{exp:channel:entries
channel=“speakers”
url_title=“anthony-towey”
limit=“1”
publisher_status=“open”
publisher_lang_id=“1”
}

<div>{title}</div>
<div>{full_name}</div>
<div>{position}</div>
<div>{talk_title}</div>
<div>{talk_abstract}</div>
<div>{body}</div>

{/exp:channel:entries}

{exp:channel:form
channel=“speakers”
url_title=“anthony-towey”
return=“Translations/speakers/URL_TITLE”
rte_selector=”.rich_text_field”
rte_toolset_id=“1”
publisher_status=“open”
publisher_lang_id=“1”
}

<div>{title}</div>
<div>{full_name}</div>
<div>{position}</div>
<div>{talk_title}</div>
<div>{talk_abstract}</div>
<div>{body}</div>

{/exp:channel:form}

 

#3

BoldMinded (Brian)

Feb 08, 2019

Comment has been marked private.

#4

Jules van Schaijik

Feb 08, 2019

Hi Brian,

I’ve tested it for a couple of hours this morning.

Now the text in both the channel:entries and channel:form tags displays the right language (specified in the publisher_lang_id parameter). But there are lots of other problems (that may have been there before, I don’t know):

• Textarea form fields display twice, both in the same language. This is true whether I use the publisher parameters in those forms or not.
• Only the edits in the second field of those duplicate textareas actually get saved. (So that the next time the form loads the text in the duplicate areas is the same.
• The edits made in a channel:form with the publisher_lang_id set are saved, not in the language indicated by that parameter, but in the language preference of the browser.

• Another thing I noticed (and wasn’t expecting) is that the value of the variable {publisher_lang_id} in a channel:entries tag follows the browser preference and not the publisher_lang_id parameter setting in that tag. (I tried the publisher_lang_id variable inside a channel:form tag as well, but there is doesn’t work at all.)

Hope this helps!

Jules

#5

BoldMinded (Brian)

Feb 08, 2019

Textarea form fields display twice, both in the same language.

This is most likely an issue with your template. Publisher doesn’t do any HTML rendering.

Only the edits in the second field of those duplicate textareas actually get saved.

Which is normal behavior when there are more than 1 field with the same name on it in a form tag. The last one rendered takes precedence.

The edits made in a channel:form with the publisher_lang_id set are saved, not in the language indicated by that parameter, but in the language preference of the browser.

Did you take a look at the docs and add the hidden fields to the form?

{exp:channel:form publisher_status="draft"}
    <input type="hidden" name="lang_id" value="{publisher:current_language_id}" />
    <input type="hidden" name="publisher_view_status" value="draft" />
    <input type="hidden" name="publisher_save_status" value="draft" />
{/exp:channel:form}

 

#6

Jules van Schaijik

Feb 08, 2019

Sorry Brian. I looked at the docs, and added the parameters, but I forgot about the hidden fields. I’ll see if that resolves things.

#7

Jules van Schaijik

Feb 08, 2019

I’m sorry if there is something obvious I’m overlooking, but I still can’t get it to work.
I have a template now with nothing but the following form:

{exp:channel:form 
 channel="copy" 
 url_title="{segment_3}" 
 return="Translations/bb_speakers_in_one_template/URL_TITLE" 
 rte_selector=".rich_text_field" 
 rte_toolset_id="1" 
 publisher_status="open" 
 publisher_lang_id="1"
 }

 <input type="hidden" name="lang_id" value="1" />
        <input type="hidden" name="publisher_view_status" value="open" />
        <input type="hidden" name="publisher_save_status" value="open" />
 
 <input type="text" name="title" id="title" value="{title}" />
 <textarea name="body" id="body" class="rich_text_field" rows="3">{body}</textarea>
 
 <input type="submit" value="Submit" />

{/exp:channel:form}

As far as I can see I have added all the necessary parameters and hidden fields to make sure the form shows the english translation (lang_id=“1”) and saves to the english translation, and that it leaves the dutch translation untouched.

But it still the browser setting that determines what translation gets edited.

Grrr..  What am I missing?

#8

BoldMinded (Brian)

Feb 10, 2019

That template code looks right. What exactly do you mean by this? “But it still the browser setting that determines what translation gets edited.”

#9

Jules van Schaijik

Feb 10, 2019

With “browser setting” I mean the language that the visitor chooses from a navigation menu.  I have this code in the navigation bar:

{exp:publisher:languages}
 <a href="http://{translated_url}hreflang={short_name}">{long_name}</a>
{/exp:publisher:languages}

So it is the setting chosen in that menu that determines the language to which the edits are saved. It overrides the publisher_lang_id parameter in the channel:form tag.

#10

BoldMinded (Brian)

Feb 10, 2019

It overrides the publisher_lang_id parameter in the channel:form tag.

If publisher_lang_id is on the channel form tag, it doesn’t matter what the user selects with the publisher:languages tag, the parameter on the tag takes precedence.

#11

Jules van Schaijik

Feb 10, 2019

If publisher_lang_id is on the channel form tag, it doesn’t matter what the user selects with the publisher:languages tag, the parameter on the tag takes precedence.

Well, then I don’t know what is going on. I am using the channel:form code I copied in #7 and the publisher:languages code in #9, and the edits follow the choice I make in #9. Perhaps there’s another factor at work.

I think I’ll try to work around the issue by using the control panel instead. That way I don’t need the channel:form tags.

#12

BoldMinded (Brian)

Feb 11, 2019

Comment has been marked private.

#13

Jules van Schaijik

Feb 11, 2019

That fixed it! Thanks brian.
One further question: is it necessary to set both the parameters like so

publisher_status="open" 
publisher_lang_id="1"

AND the hidden fields like this?

<input type="hidden" name="lang_id" value="1" />
<input type="hidden" name="publisher_view_status" value="open" />
<input type="hidden" name="publisher_save_status" value="open" />

It seems redundant.

#14

BoldMinded (Brian)

Feb 11, 2019

Yes, it is, b/c the parameters tell it what to load, and the hidden fields tells it what to save as. It’s possible someone could use a select menu for the lang_id field and change which language the entry is being saved as.

Be sure to check out normal CP based entry saves with this change, especially if you’re using Grid, Relationship, or other complicated field types (like Assets). I had to make a change that touched quite a few files to fix this and I want to make sure I didn’t break anything. My tests looked good, but the more eyes on it the better.

#15

Jules van Schaijik

Feb 12, 2019

I’ll try to keep an eye out for issues and point them out as I go along. Do let me know if it gets tiresome.

This morning I noticed that when something goes wrong in the channel:form (an invalid entry or something like that) publisher does not work on the return template. That is, after submitting the form, it gets returned with error messages, and on that page publisher isn’t working. Phrases don’t translate, the language code isn’t added to urls, etc.

#16

BoldMinded (Brian)

Feb 12, 2019

Jules, I’ll try to take a look at this later in the week. This sort of issue doesn’t sound like its a quick fix.

#17

BoldMinded (Brian)

Feb 12, 2019

Actually the saving issue sounds like it should be a new ticket, instead of dragging it out in this one. Would you mind creating a new ticket with the details of what is occurring, and perhaps a video of it happening?

#18

Jules van Schaijik

Feb 12, 2019

I’m pressed for time now, but will try to get to it next week. I think there are still other issues as well, that I need to get a better grasp on before being able to explain more exactly.
Many thanks for your help so far!

#19

BoldMinded (Brian)

Feb 12, 2019

Sounds good. I’m going to go ahead and close this one. If you remember, you can link to this ticket from the new ticket just for reference.

Login to reply

Contact

For add-on support, please use the Support section. General inquries and pre-sale questions can be sent to support@boldminded.com.