Closed (fixed)
Project:
Panelizer (obsolete)
Version:
7.x-3.x-dev
Component:
Code
Priority:
Critical
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Aug 2013 at 14:32 UTC
Updated:
9 Feb 2019 at 04:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
merlinofchaos commentedThe simplest way to achieve this would be to use hook_entity_view_mode_alter() (I think that's the hook; it's the hook that lets you change the view mode) and switch it on the language; then use view modes to display the entity appropriately. It's a relatively small amount of code and extremely flexible, without increasing the UI complexity any more than it already is.
Comment #2
seanr@merlinofchaos - could that be combined with panelizer? I've got the same requirement as the OP. The client is already used to panelizer and they do tons of arbitrary content placement (truly ridiculous amounts of it, in fact, LOL).
Comment #3
kle commentedThank you merlinofchaos. I managed the problem but forgot to give you my tribute !!
Comment #4
seanrMerlin, can you describe your suggestion in more detail?
Also, what about adding an extra column to the panelizer_entity for language? Each node would have a default did for all languages, and you could then override it for a specific language, resulting in a new recording in panelizer_entity referencing that language with the new did (which starts as a clone of the original).
A related question is how do selection criteria work in regular panels with multiple displays? Is that possibly something that could be leveraged?
Comment #5
damienmckennaThis really should be supported out of the box.
Comment #6
dimitrov.adrian commentedHi, I just create a patch, which seems to work fine.
The only problem (which itself isn't small) are the panes created by Fieldable Panel Panes which are not cloned but referenced. Anyway, there is a issue about it too https://www.drupal.org/node/1806430
Comment #7
dimitrov.adrian commentedComment #8
japerrynow that we're using panelizer, we too are needing this feature. The patch works for us in its simple format.. but we'll have to investigate more use cases.
Comment #9
ruloweb commentedHi all,
I added to the patch in # 6 the FPP cloning based on #1806430: Cloning fieldable panels panes via IPE, so when you clone the node, its display and FPPs are cloned too.
This is a first approach, I think that FPP cloning must to be done in FPP module, probably we could add a new hook in panelizer_clone function in orden to allow that.
Thanks!
Comment #11
ruloweb commentedRe upload interdiff as txt file.
Comment #12
damienmckennaReroll. And it needs tests.
Comment #13
jhodgdonWe are apparently running this patch from #12 on drupal.org.
I believe it is causing the following problem: When you add a node translation, it is *always* getting set to have a Custom panelizer setup, even if the source node is set to use the Default. Thereafter, when you change the Panelizer setup for a content type, the translated nodes don't get the updates, which is bad.
See #2858174: Content panes not showing up in translated nodes using Panelizer, which is most likely a duplicate. It is causing problems for the User Guide, which has 6 translations so far, and we may also be translating other Documentation content on drupal.org in the future. With this happening, any updates to the Panelizer config are not showing up on translated nodes, because Panelizer thinks they have custom config.
I think the code in this patch is causing the problem, but I'm not sure how to fix it...
Comment #14
jhodgdonThis looks like the lines that are most likely causing the problem for drupal.org. It is always being set to CUSTOM. ?!?
So up above a few lines:
Should this maybe check whether the translation_source had custom or default setup, and only clone if it was customized?
Comment #15
jhodgdonHere is a fix that I think works to skip cloning and setting to Custom if the source language wasn't custom.
I have verified that if you translate a node that wasn't customized, it comes through as also not customized.
I haven't tested it in any other way...
Comment #17
damienmckennaI think a test that documents what should work would help round about now.
Comment #18
damienmckennaAs a step towards tests, could someone please clearly define the expected steps with Panelizer on translated content? I'm especially interested in what is the expected outcome if an entity's display is customized and it's then translated to something else using either a) Content Translation (which clones the existing node) and b) Entity Translation (multiple languages on one node).
Comment #19
damienmckennaDisclaimer: I can work on the tests but I need to know what the expected behavior is from the people who need this.
Comment #20
jhodgdonTypo in that last patch...
Comment #21
jhodgdonHere are my thoughts on #18:
Expected behavior if a node has not been customized: the translation is also not customized.
Expected behavior if a node has been customized: the translation receives the same customized panels.
Expected behavior on editing later: Editing either the source language or any translation's Panelizer settings (changing customizations or changing from default <-> customized) should not affect any of the other translations.
I don't think the answers to these depend on whether the node is using core Content Translation (multiple nodes) or Entity Translation (one node). The code/storage may be different, but the expectation should be the same. The point of this issue is that you want to be able to have different Panelizer settings for each translation, so they need to be independent; but when you are initially creating a translation, the sensible thing is to copy what the source node has (but not mark it as customized if isn't).
Comment #22
jhodgdonRegarding the patch in #15/#20, there was a typo, so I also tested the patch in #20 and it still works for my use case (node without customization, translated using Content Translation ==> no customization in translation).
Comment #23
drummThe logic here makes sense to me - we want to only have customized pages when necessary, so changing the default layout is effective.
I had #20 briefly deployed to Drupal.org, but had to revert.
empty($panelizer->name && $panelizer->name == $default_display)usingempty()on an expression instead of just a variable became supported in PHP 5.5, which is all good for Drupal.org’s www servers. But our Git servers are still stuck on an earlier version.Comment #24
damienmckennaI am sorry for not getting to this sooner. I'm busy this week with a presentation to finish for NERDSummit, but next week I'll put some time into this.
Looking at it really quickly, I suspect that empty() line might be a typo.
Comment #25
jhodgdonYeah, that empty() line should read:
I think.
Comment #26
jhodgdonHere's a new patch, with just that one line changed.
Comment #27
drummI know this needs tests, but I'd kinda like to see a DrupalCI run before considering deploying.
Comment #28
drummBack to the correct status.
Comment #29
drummI tested #26 on a www.drupal.org dev site, and it looks good for Drupal.org. If a non-custom node is translated, the translated node is also not custom. (I did not test other behavior because I’m lazy and we want to avoid too many custom pages.)
Comment #30
damienmckennaHas anyone tried the patch with FPP disabled? Specifically I'm wondering what happens with
ctools_get_content_type('fieldable_panels_pane');if the module is not installed?Comment #31
damienmckennaIn fact, is there even any need to do
ctools_get_content_type('fieldable_panels_pane');? The$pluginvariable isn't used anywhere and both of the two FPP functions are in the main module file, so does this work?Comment #32
damienmckennaAlso, what's the point of the $entity_info logic when cloning the FPP? The FPP primary ID is 'fpid' and there is no $entity_info['entity keys']['name'] per fieldable_panels_panes_entity_info(), so all of that logic can be shortened.
Comment #33
jyve commentedThis is great functionality. However, it seems that this does not work wel with pane revisions. It clones the first revision, while I would expect it to be the last revision?
Comment #34
damienmckennaIt clones the "active" revision, not the first.
I wonder should the custom logic be moved into FPP? We could add a new hook to clone_panelizer() and then implement the hook in FPP.
Comment #35
damienmckennaGoing to get this into the next release. I'm also going to split it in two and put the FPP-specific code into FPP, per #34.
Comment #36
damienmckennaThis adds hook_panelizer_display_clone() to handle cloning the display.
Comment #37
damienmckennaRenamed the hook to hook_panelizer_clone_panelizer() and moved it inside PanelizerEntityDefault::clone_panelizer().
Comment #38
damienmckennaI split the FPP part into #2962952: Implement hook_panelizer_clone_panelizer().
Comment #39
damienmckennaSo the new tests should step through having a custom display for a translatable node, then translate the node and see what happens to the Panelizer object.
Comment #40
damienmckennaI think this part should change:
I think ::clone_panelizer() should handle resetting the UUIDs.
Comment #41
damienmckennaSome refinements - handle the UUID resetting in clone_panelizer(), and skip the redundant code to copy the the panelizer structures over before cloning them.
Still needs tests.
Comment #42
dsnopekI don't know if this should be done on this issue or another, but the cool cloning logic used here should probably be reused in Panelizer's implementation of
hook_clone_node_alter(). I can come up with a patch for that!Also, I'm not sure about the name of the
hook_panelizer_clone_panelizer(): it acts like an alter hook, so something likehook_panelizer_clone_alter()would make the most sense to me.What do you think?
Comment #43
dsnopekHere's what I was thinking for
hook_clone_node_alter(). I haven't had a chance to test this yet - sorry!Comment #44
dsnopekI found a tiny bug in the patch. But, otherwise, I did some quick testing and this appears to work great!
Comment #45
bmunslow commentedThanks for the work on this patch.
The patch does work for core Content Translation, however it has no support for Entity Translation at the moment.
Reviewing the patch, I can see it only acts on
hook_entity_insertat the moment.Should support for Entity Translation mode be included in this patch? or should we deal with it on a separate issue?
Comment #46
jhodgdonI would say supporting Entity Translation should be a separate issue, but I am not a maintainer of this module.
Comment #47
damienmckennaI'd request that support for Entity Translation be handled in a separate issue.
Comment #48
hugronaphor commented@DamienMcKenna would you come with a theoretical plan of how Entity Translation should be integrated with Panelizer so the community can start with something?
Comment #49
damienmckennaPer cboyden's comment in #2962952-9: Implement hook_panelizer_clone_panelizer(), this is RTBC.
Comment #50
damienmckenna@hugronaphor: I'd suggest moving that discussion to #3023760: Properly support Entity Translation.
Comment #52
damienmckennaCommitted. Finally. Thank you everyone!