Jump to content

Recommended Posts

Posted

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
Posted

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
Posted

Of course that’s the obvious thing to do. But it takes a lot of space and makes my (already) complex repeatermatrix items even more complex... Any ideas for "hacking" oder "hooking" into these little icons in the top right corner?

Posted
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.

Posted
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
Posted

Maybe I’ll just build the language-dependend "show/hide" switch as a hidden field, and then write a little bit of custom javascript to somehow make it very compact in the top right corner. Let’s see how that works out.

  • 2 months later...
Posted

Hey @gerritvanaaken, did you come up with a solution yet? I want to accomplish exactly the same, and this is how I implemented it:

image.thumb.png.62136353b1ecac4745db334c303755e1.png

It's a Page Reference field, displayed as checkboxes. Now I try to use a similar code like @MoritzLost posted above, in my Smarty template.

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
×
×
  • Create New...