If the "Default panel" selector is changed on an entity/bundle, there's no way to automatically update existing entity objects to use the new default, they'll all still use the old one. Need to add an option on the display to update existing records if the values are changed.

Comments

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new3.91 KB

This appears to work, though the node caches are not cleared afterwards.

damienmckenna’s picture

StatusFileSize
new4.36 KB

This version checks if EntityCache is enabled, if so it'll clear the caches for this entity type. It's a little heavy-handed, but I don't know if there's a reliable way of clearing caches for only objects of the specific entity bundle.

damienmckenna’s picture

StatusFileSize
new4.44 KB

This resolves problems if the $old_value was unset.

damienmckenna’s picture

Status: Needs review » Needs work

Needs to be added to the main Panelizer settings page too.

saltednut’s picture

StatusFileSize
new60.82 KB

I am seeing the checkbox to update under /admin/structure/types/manage/[bundle] but when I save the node settings form I see the following error.

Notice: Undefined variable: old_bundle in PanelizerEntityDefault->add_bundle_setting_form_submit() (line 822 of /modules/contrib/panelizer/plugins/entity/PanelizerEntityDefault.class.php).

It looks like you are trying to use a variable called $old_bundle that does not exist.

In addition, when I go to the panelizer settings, I do not see this option. But it is another place where I could change this setting.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new4.28 KB

This version works without the errors.

damienmckenna’s picture

StatusFileSize
new9.4 KB

This version adds the same link & necessary logic on the main settings page.

saltednut’s picture

Just tested this inside the 'WEM Demo' of Demo Framework.

Scenario 1:

  1. Install Demo Framework with the 'WEM Demo' option checked
  2. Enable panel choice and clone the default display for 'WEM News'
  3. Visit the /admin/structure/types/manage/wem-news page
  4. Change the default layout to this newly cloned layout
  5. Check the checkbox to update existing entities and click Save
  6. No errors! I get a message that says "36 node records were updated to the new Panelizer display for the page_manager view mode."

Scenario 2:

  1. Install Demo Framework with the 'WEM Demo' option checked
  2. Enable panel choice and clone the default display for 'WEM News'
  3. Visit the /admin/config/content/panelizer page
  4. Change the default layout to this newly cloned layout
  5. Check the checkbox to update existing entities and click Save
  6. It works, "36 node records were updated to the new Panelizer display for the page_manager view mode."

This works for me, but I did find one edge case:

Repeat steps above in either scenario, but leave out step 5 (checking the checkbox). This updates the default display only for new entities (works as designed). However, if I had forgotten to check the checkbox, but I wanted this change to be enacted, I wouldn't be able to just check it now and save. Nothing would happen, per "Note: only takes effect when the display is changed, and will not work if the default was not assigned previously."

I can work around this by changing the display back to the previous version, then click save (no checkbox needed). I'm then back to a state where I could run through the workflow again, changing the default panel and this time and remembering to check the checkbox.

In short: It might be nice to allow people to check the checkbox later on in time or if they forgot to check it.

damienmckenna’s picture

I don't think there'd be a good way of expanding the current logic without running into a ton of problems. Also, once I work out the necessary #states logic I'm planning on hiding the new checkboxes until the selector is actually changed.

I'm intending to have full (working) VBO support soon, and a default admin page where people could manage that, and when that's working I'll add a link (with appropriate permission checks) in the Panelizer settings forms.

saltednut’s picture

Status: Needs review » Reviewed & tested by the community

Ok. That makes sense. We can post followups for that feature.

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the help reviewing it, Brant.

Committed.

  • DamienMcKenna committed f5e1fcc on 7.x-3.x
    Issue #2332997 by DamienMcKenna: Option to update entities when changing...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.