-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Allow shortcodes to be rendered without invoking Civi page #244
Conversation
@colemanw I see what you're trying to do here but I would prefer a new filter rather than repurposing an old one. Duplicating the My preference would be to let // The absence of a route/path needs special handling.
if ($args === FALSE) {
// Default markup for an improperly constructed shortcode.
$markup = '<p>' . __('Do not know how to handle this shortcode.', 'civicrm') . '</p>';
/**
* Filter the markup for "pathless" Shortcodes.
*
* This filter allows plugins or CiviCRM Extensions to modify the markup used
* to display a shortcode that has no CiviCRM route/path. This may be:
*
* * Accidental due to an improperly constructed shortcode or
* * Deliberate because a component may not require a route/path
*
* @since 5.36
*
* @param str $markup The default markup for an improperly constructed shortcode.
* @param array $atts The shortcode attributes array.
* @param array $args The shortcode arguments array.
* @param str Context flag - value is either 'single' or 'multiple'.
* @return str The modified shortcode markup.
*/
return apply_filters('civicrm_shortcode_get_pathless_markup', $markup, $atts, $args, 'single');
} Obviously the second code block would have Also, please note the docblock for the filter - these are now rigorously enforced in this plugin ;-) We're planning to use |
Thanks for the review @christianwach. I think you may be mistaken about the impact on existing code that uses the filter. My intention was that this change would allow all current extensions/plugins to work without modification. Could you please take a second look? I believe the new 'single' mode will only run in the case of a missing
In the event that they are poorly-written and are failing to check |
Yes, true but...
This is not necessarily true. There could be callbacks that alter any of the elements in the
And now callbacks such as I've described above will run if it's an Afform shortcode in "single" mode because Afform does not implement My point is that a new filter is risk free (not sure what you mean by "current implementations of the filter will continue to work as normal" in this context) whereas re-using |
c2210cc
to
dd7eb67
Compare
@christianwach ok those are good points. I've thought it through some more and have created a new filter: |
@colemanw So does this mean you're adding callbacks for both |
I do? Sigh, I guess we should have all sat round and discussed this before I wrote and scrapped so much code. |
@colemanw Never too late :-) Ping me on MM if you want to set up a chat. |
This allows civi core or extensions to supply content for shortcodes without rendering a page; they can simply implement `civicrm_shortcode_get_content` and return the content. This new filter is called whenever displaying contents of a pathless shortcode. See civicrm/civicrm-core#19687
dd7eb67
to
07e42f2
Compare
@christianwach I've reworked this per your suggestions. |
@colemanw so for testing via
It also looks like I'll need to enable the old editor in WP as the modal won't work any longer. Do we have documentation on what the shortcode syntax is as users cannot add via modal any longer? |
When you submit on a WP page, there is no indication to the user that the form was successfully submitted other than a brief 'toast' alert in the upper right hand corner. Is that expected? |
Sounds like you got it working. |
Thanks @colemanw I have a bit more to do on existing shortcode testing, but this is working as you expect. I am reluctant to have this merged until we have the redirect. I am not against it - but I think the form staying on the same page, no apparent visual cue that it was successful will frustrate users. I created 3 contacts before I realized what was happening - So perhaps I didn't explicitly set a dedupe rule and it did not use the unsupervised one. I get that one has to enable Form Builder, build a form before we even get to the shortcode part - which is why I am not against this. I just am concerned about this being very alpha stage right now. @christianwach what do you think? Am I overthinking this? |
Well Afforms have different purposes, and some are not actually forms with submit buttons, for example a search display listing or directory, which was the use-case I had in mind. |
@kcristiano it does also enable searches to be embedded which is probably what people are more likely to try out given the current focus & which don't have the same issue |
I did say I am not against it :) I understand we want this in early - I do see searches have a more immediate impact. When are we cutting RC? Do we have a deadline? I like deadlines |
@kcristiano rc gets cut today |
@eileenmcnaughton Lacking feedback from Christian, I am OK to see this merged but would hope we could handle any concerns he raises during RC. I think civicrm/civicrm-core#19687 should be merged first. |
@kcristiano ok - I'll merge them - I doubt many people will discover them in 5,37 but it would be good to have them merged for it so they can start to experient at the bleeding edge & yeah I'm sure @colemanw will leap on any fixes |
Note that we will target the rc for any follow on fixes |
That's good to hear - the functionality of Afforms displayed via the Shortcode seems... unfinished. From a usability perspective, the lack of obvious feedback and not clearing the form is going to confuse people unless addressed. Other than that, it's great to see progress 👍 |
@christianwach yeah - I think afform is still marked beta which gives us a little scope to be a bit beta-ish |
This allows civi core or extensions to supply content for shortcodes without rendering a page; they can simply implement
civicrm_shortcode_get_markup
and return the content.This new filter is called for any shortcode that does not specify a
q
parameter.See civicrm/civicrm-core#19687