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

Wrapping content within shortcodes? #4

Open
DevJMD opened this issue Aug 11, 2020 · 1 comment
Open

Wrapping content within shortcodes? #4

DevJMD opened this issue Aug 11, 2020 · 1 comment

Comments

@DevJMD
Copy link

DevJMD commented Aug 11, 2020

In your second example, you use:

[text color="red"]This is red text.[/text]

What if This is red text. is dynamic content? Take for example, a wrapper element.

HTML:

<div class="wrapper"></div>

Shortcode:

[wrapper] My dynamic content that could contain lots of HTML from the user [/wrapper]

How would I go about this? For example, My dynamic content is injected within <div class="wrapper"> My dynamic content </div>?

Maybe I'm overthinking this, but I want to use this in a WYSIWYG and I know a very similar service for Laravel lets you access the $content within the tags which renders anything between the shortcode tags.

The idea I have in my head is:

<div class="wrapper">{{ content }}</div>

Thus dynamically rendering the content between [wrapper] and [/wrapper].

Is there a way to achieve this or access the content within the shortcode tags?

I'm going to take a slight guess and presume this may involve passing the content as a controller argument somehow?

It's not that I want to inject content as such by parameter, but HTML pre-existing through the WYSIWYG.

Cheers,
J

@sebastiankugler
Copy link
Member

Hi James,

That sounds like a very valid idea. We simply didn't have this use case yet and thus this bundle doesn't provide access to the content between the shortcode tags.

The library we're using (https://github.com/thunderer/Shortcode) seems to support accessing the content via the getContent() method of the shortcode. To my understanding, it should be possible to pass the content to the controller in the __invoke method of the EmbeddedShortcodeHandler (https://github.com/webfactory/WebfactoryShortcodeBundle/blob/master/Handler/EmbeddedShortcodeHandler.php#L77).

A PR adding this feature would be welcome!

Cheers,
Sebastian

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

2 participants