Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 4 years ago

#2432 closed enhancement (maybelater)

display multiple messages / notices via bp_core_render_message

Reported by: aesqe's profile aesqe Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Toolbar & Notifications Keywords: trac-tidy-2018
Cc: aesqe@…

Description

Example (custom component):

user creates a new post = success;

but in process, some of the files they uploaded are not of image mime type = error;

I'd like to be able to display both messages.

I've tried combining both messages into a string, separated by a <br /> tag, but the bp_core_render_message kills it by doing "stripslashes( attribute_escape( $bp->template_message ) )", and only one $type can be set, anyway.

I could probably produce a patch in a few days, if no one objects?

Attachments (2)

bp-core-messages.patch (3.9 KB) - added by aesqe 12 years ago.
adds support for adding and displaying multiple success/error/etc messages
2432.2.patch (3.8 KB) - added by boonebgorges 12 years ago.

Download all attachments as: .zip

Change History (10)

#1 @aesqe
12 years ago

This is my first try at submitting a patch, I hope it'll work :)

It's just an example of how displaying multiple messages could be achieved. I'm sure this can be implemented even better, but it works just fine for me on one production site.

@aesqe
12 years ago

adds support for adding and displaying multiple success/error/etc messages

#2 @boonebgorges
12 years ago

Thanks for the patch, aesqe.

I reworked it a little bit. I think it's a great idea for BP to support multiple simultaneous template notices, but it doesn't seem urgent to me that bp_core_add_message() lets you add them in a single line. It ends up making the function a bit unwieldy, with all the is_array stuff.

Instead, I've implemented the idea of a template_notice "stack", and when you call bp_core_add_message() it checks for the existence of the stack, and if it finds the stack, it adds the new message on top.

It works really well on my installation, but I would like others to do a sanity check for me. I'm especially concerned about the base_64 encoding for cookies - I agree with aesqe that serialized cookies can be problematic, but this base_64 workaround is new to me. Again, it works well on Mac Chrome, Safari, and Firefox, but it'd be nice if it were run through a few other browsers too.

#3 @DJPaul
11 years ago

  • Component changed from Core to Theme
  • Keywords notices messages removed
  • Milestone changed from 1.3 to Future Release

#4 @boonebgorges
8 years ago

  • Severity set to normal

Just found this ticket and still think it's a good idea, but it obviously needs a refresh. My proposal:

  • Use json_encode() to create the cookie value instead of base64. This will allow us to store structured data more reliably.
  • Store the cookie data like this:
[
    'success': [
        'This is the first success message in the stack',
        'This is the second'
    ],
    'error': [
        'Oh no! An error',
        'Sheesh! Another'
    ]
]
  • When parsing for display, stack all the success messages in a single success box, and put all the error messages in a separate error box. (This will take some reworking of the way that content is sanitized, so that we can use, say, <ul><li> in the error box.)

Only real concern here is backward compatibility. Any plugins or themes that are directly referencing the message values in the global or in the cookie will be broken. I'd be surprised if anyone were actually doing this, but still. There may be issues with creating more than one 'message' box, because I think we might use #message rather than .message (and breaking the selector will break custom styling). And if anyone has a message stored in their cookie prior to an upgrade, and then visits the site after the upgrade, it won't be displayed correctly (very very edge case that we can fail out of gracefully, I suppose).

Anyone have thoughts about the above before I patch it?

#5 @DJPaul
6 years ago

  • Component changed from Appearance - Template Parts to Templates

#6 @DJPaul
6 years ago

  • Component changed from Templates to Toolbar & Notifications

Supporting display of multiple messages is a fine enhancement, but I would like BuddyPress to not use a cookie to store this sort of status message. I can't believe there's not a more sane approach somewhere.

#7 @DJPaul
4 years ago

  • Keywords trac-tidy-2018 added

We're closing this ticket because it has not received any contribution or comments for at least two years. We have decided that it is better to close tickets that are good ideas, which have not gotten (or are unlikely to get) contributions, rather than keep things open indefinitely. This will help us share a more realistic roadmap for BuddyPress with you.

Everyone very much appreciates the time and effort that you spent sharing your idea with us. On behalf of the entire BuddyPress team, thank you.

If you feel strongly that this enhancement should still be added to BuddyPress, and you are able to contribute effort towards it, we encourage you to re-open the ticket, or start a discussion about it in our Slack channel. Please consider that time has proven that good ideas without contributions do not get built.

For more information, see https://bpdevel.wordpress.com/2018/01/21/our-awaiting-contributions-milestone-contains/
or find us on Slack, in the #buddypress channel: https://make.wordpress.org/chat/

#8 @DJPaul
4 years ago

  • Milestone Awaiting Contributions deleted
  • Resolution set to maybelater
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.