Jump to content

Idea: Language config in repeater(matrix) items headings


gerritvanaaken
 Share

Recommended Posts

Wouldn’t it be cool to have whole repeater items (or even repeater matrix items) language-specific. Some of my clients do have pages that are 90% identical in German and English, but there are some sections that should not appear in one or another language. I attached a concept screenshot.

Would something like this be possible with some simple backend hooks and "hidden checkbox fields"? Or is it way more complicated?

 

pw-lang-repeater.png

  • Like 5
Link to comment
Share on other sites

One simple way to do this client side with normal fields would be to add an "Active languages" field to each Repeater Matrix type, and use that as a language activation switch. For example:

Create a Page Reference field "active_languages" with the template "language" as selectable pages and the input field type set to checkboxes. Then add that field to each repeater matrix type. Finally, in the code that renders the matrix item, use something like this (code untested):

// assuming the matrix field name is "sections"

foreach ($page->sections as $section) {
  $if ($section->matches("active_language={$user->language->id}") {
      // render the field
  }
}

Now the editor can check which languages they want the section to be displayed in. Obviously you can also invert the logic and use the checkboxes to hide the section in a specific language.

Of course, having this built in would simplify things a lot ?

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, gerritvanaaken said:

But it takes a lot of space and makes

Your proposal of adding toggle to the bar can take up lots of space too, if there are lots of languages in the system, so perhaps another way of solving the issue would be more feasible. Anyway, I get your point and the feature itself would be welcome, of course.

BTW, while we are talking about the horizontal bar of a repeater matrix item, I find it annoying that the open-close toggle (the arrow icon) is not on the far right, because there is the case of the "Show settings?" cog icon appearing between the "arrow" and the "duplicate page" icons, and when that happens the arrow of the open-close toggle moves upon clicking on it. So in that case it is not possible to quickly open and close a repeater item, one has to reposition the mouse pointer all the time.

Link to comment
Share on other sites

58 minutes ago, szabesz said:

Your proposal of adding toggle to the bar can take up lots of space too, if there are lots of languages in the system, so perhaps another way of solving the issue would be more feasible. Anyway, I get your point and the feature itself would be welcome, of course.

Definitely would love to have such options. Language togglers could be hidden under same panel as 'change matrix type' panel. 

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...