-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditional alert banner placement #142
Conversation
Ref #120 Required condition_field https://drupal.org/project/condition_field Adds experimental support for when a condition field named field_conditions is present on a banner, evaluate visiblilty
Includes update path for field_condition schema. See: https://www.drupal.org/project/condition_field/issues/3215202#comment-14117352
This is now ready to be reviewed. |
I've checked out this update. A couple of questions: Also it is showing the content type and user role contexts, are we planning on restricting the plugins initially in use? |
@andybroomfield agree that the conditionality ought to work out of the box for all banner types On the alerts work, @stephen-cox hid/ removed content type and user role controls so could you do the same here? Thanks both |
I think it is hidden in the config so a fresh install won't show them, this was testing an upgrade with existing alert banners. |
@andybroomfield I have updated the code so the visibility field should be added to all existing alert banner bundles. Only the pages visibility plugin should be added to existing alert banners. Can you check whether the condition_field module was patched with the latest patch from here: https://www.drupal.org/project/condition_field/issues/3215202? If the patch is not installed then the condition field doesn't work properly with the provided configuration. |
@stephen-cox Ok thanks. I've applied the patch and re-run the update. This is working as expected with adding the condition field to all alert banner types and only the page plugin is enabled by default. One bug I have encounterd. When logged in as admin and setting up a page restriction, the banner only displays once on the restricted page. Then visit a page where it should not show and go the the page it shold show. Refreshing that page and the banner goes away. This is only logged in users (presume cache for anon). I think this could be cache issue as then flushing cache brings it back. So the route of the page needs to be a cache context for the banner or the block? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, this is broken with cache. Disbling the cache backends and it works as expected. With caches enabled, going to a page with a restricted banner, then going to a page without a banner, and then revisiting a page where there should be a banner, the banner will not be present. Flush cache then makes it appear (and appears on all pages).
…ew() hook and into the AlertBannerEntity and AlertBannerBlock clases
@andybroomfield The latest changes should fix the caching issues. They represent quite an overhaul of how the visibility conditions are evaluated, along with changes to the alert banner block. Are alert banners only currently displayed to end users through the alter banner block? If so then the changes should be fine. If there are other ways of displaying them they will need to be updated to use the |
Thanks @stephen-cox will look. Yes at present it is just the block for end users. I think it is safe to document that if someone is using them outside a block, it is on them to check the isVisible() condition. The main use case I can think of is if someone built a view instead, so maybe a views filter plugin in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just checked this and it works with cache on.
Happy for this to go forward for release.
As new feature, this is a v1.1.0?
Thanks @andybroomfield. Merged. I'll create a PR for the new release. |
Closes #137