It would be awesome if the WYSIWYG shows the rendered shortcode, instead of the brackets.
We could have a look how the Media module does this, as they use brackets too. I believe they parse the brackets with Javascript after inserting the tag.

Would this be manageable?

Comments

cbeier’s picture

This feature is very tricky to implement. Also, in the WordPress the shortcodes are not rendered in the editor. The integration of that functionality in the media module is very special (insert generated html to the editor, extract the (media) html tags and convert it back to the media markup if the editor is detached, …). But with the flexibility that shortcodes can have, the convert process from editor html back to the shortcodes markup will be hard to act.

drupov’s picture

Priority: Normal » Minor
Status: Active » Postponed
mcfilms’s picture

Just so I am clear, at this point in time there is no Drupal equivalency to the WordPress shortcode function of adding the content of one post (or node, or generated block) to the middle of an HTML body.

That's not meant to be snarky, I am trying to assess if I can do what I want to do (relatively) easily.

hixster’s picture

@mcfilms we built a whole bunch of shortcodes which do what you want - we may contrib if we get time.
Increasingly we use shortcodes for everything, forms, nodes, views rendering or list rendering.
The whole using blocks and regions to build sites is outdated now, customers want forms inside their content or a teaser here or there.

We settled on a generic content short code which takes arguments and looks a little like this:

[content type="node-type" ids="a list of ids" category="a list of term ids" viewmode="the display mode"]

We also have options for sticky, published, language, ignore permissions and that kind of thing.

I'll see if can contrib this stuff back at some point - it really opens up the flexibility of Drupal.
Lastly, and I hate to say it, but after 6 or so years of hardcore Drupal development Wordpress really is becoming a more attractive proposition, which short does being almost a standard with widespread support.

mcfilms’s picture

@hixster -- I hear you. Two of the last three projects I have done were on WordPress. Quite frankly the out-of-the-box WordPress UI is better for content creators and now it seems to be getting better for devs.

Simply put, the use of shortcodes in WP is fantastic. Sure, I can emulate this in Drupal by writing custom page.tpl.php files, but, really? Adding a form or a block by typing in a reference in brackets is SO easy.

I really hope you can get around to contributing your work. I'd be very interested in testing and giving feedback and helping with documentation.

Cheers!

drupov’s picture

Totally agree with #4 and #5.

And yes, would be cool if we can contribute to and test your code!

jmuzz’s picture

Issue summary: View changes
StatusFileSize
new23.46 KB

Here's a patch that changes how shortcode_wysiwyg works to accomplish something like this. It isn't perfect, but here is what it will do:

  • Shortcodes will be represented in the WYSIWYG by a generic placeholder graphic.
  • The graphic can be selected and the shortcode button pressed to change the settings of the shortcode.
  • Each type of shortcode will have a value and an align property added.
    • The content of value will be placed between the open and closing shortcode tag.
    • The align can be left, center, or right by default, and is added as a normal shortcode attribute as well as changing the inline style of the preview. It does not change how the shortcode is displayed in content.
  • The popup will appear as soon as the button is pressed and display "Loading..." until the forms are downloaded instead of seeming to do nothing when the button is pressed until the forms are loaded.
denes.szabo’s picture

Project: Shortcode » Shortcode for Wysiwyg

Moved to the shortcode_wysiwyg project.