Skip to content
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

Way for shortcake interface to remember user shortcode parameters #742

Open
coolwebs opened this issue Jun 12, 2017 · 4 comments
Open

Way for shortcake interface to remember user shortcode parameters #742

coolwebs opened this issue Jun 12, 2017 · 4 comments

Comments

@coolwebs
Copy link

Is there a way for the Shortcake plugin to remember user parameters that have previously been entered?
The plugin works perfectly in the first instance creating a shortcode on the page/post. However, when user wants to edit the shortcode, the modal window does not seem to remember the user specified settings/parameters.

Any 'text' field does this perfectly and that does not appear to be the issue. However, when I introduce select fields or checkboxes/radio buttons, the user data is not displayed when editing the shortcode using the Visual Editor. Is there a hook or function I can use to get the editor to remember this information?

@goldenapples
Copy link
Contributor

I'm confused as to what behavior would make sense here. Text input fields do what you're describing out of the box through browser autocomplete functionality. For other field types, there isn't an autocomplete UI built in to the field itself, so we'd have to style something custom.

If you want to do this yourself for a specific shortcode (ie, when creating a new instance of a shortcode, pull certain values from the last edited instance of that shortcode, you could use the send_to_editor js hook from #681 (once that's merged) to save values for the fields you want to autopopulate, and then set them on a new shortcode using the render_edit js hook.

@coolwebs
Copy link
Author

Sorry for not being clearer. I think the issue I am experiencing is directly related to #738

@cowanr
Copy link

cowanr commented Jun 15, 2017

@coolwebs

For a short term fix until the next release I just grabbed the code from the issue #738 with one minor tweak. The fix didn't address multi selects so instead of an empty split, i used a comma as the separator and I don't use commas in any select values. Not ideal but was simplest way for me until this gets worked out with a release and I can move on to other things.

<option value="{{ option.value }}" <# if ( ! _.isEmpty( _.filter( _.isArray( data.value ) ? data.value : data.value.split(","), function(val) { return val === option.value; } ) ) ) { print('selected'); } #>>{{ option.label }}</option>

@coolwebs
Copy link
Author

Thanks @cowanr - that certainly resolves my issue for the meantime!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants