- This topic has 5 replies, 3 voices, and was last updated 3 years, 5 months ago by
David.
-
AuthorPosts
-
October 31, 2022 at 1:59 pm #2395968
Shannon
Is it possible to have an element or reusable pattern shortcode?
Here’s my use case:
I would like to place an element inside an HTML field in Gravity Forms. This field serves as a type of “cover page” with details about the form as well as an introduction. There are graphic elements in the layouts as well which is why I was hoping to use GP+GB to create the cover page layout. I tried copy/pasting the code but they styling information wasn’t picked up.Does that make sense? Is it easily achievable?
Thanks,
ShannonOctober 31, 2022 at 6:22 pm #2396091Ying
StaffCustomer SupportHi there,
I tried copy/pasting the code but they styling information wasn’t picked up.
It’s not possible as GB’s style is not added to the HTML, it’s generated dynamically.
November 1, 2022 at 9:07 am #2396990Shannon
Thanks Ying.
So this is not possible via a hook or shortcode either?
November 1, 2022 at 9:39 am #2397034David
StaffCustomer SupportHi there,
you can try creating a Shortcode that has a Hook inside it with this PHP Snippet:
function portable_func($atts, $content = null) { ob_start(); do_action('portable_hook'); return ob_get_clean(); } add_shortcode('portable-shortcode', 'portable_func');Then in your gravity form HTML add your
[portable-shortcode]shortcode.Then create a GP Block Element – Hook to create your content and set the Hook to
Customand in the field provide add :portable_hookCan’t say how gravity will deal with that, or whether the styles will load correctly. But thats about all we have
November 1, 2022 at 12:47 pm #2397285Shannon
David,
That worked great, thanks!
I used the same snippet and shortcode for 5 different element variations. One for 5 different Gravity Forms. I did however set the display rules for each element to only display their respective pages.
Is this okay? Do I need to create 5 different snippets with 5 different corresponding shortcodes in order to avoid any conflicts?
Thanks again.
November 2, 2022 at 2:11 am #2397821David
StaffCustomer SupportIs this okay? Do I need to create 5 different snippets with 5 different corresponding shortcodes in order to avoid any conflicts?
If the Shortcode only ever appears on one page. And each element has different display rules. Then one shortcode is good.
-
AuthorPosts
- You must be logged in to reply to this topic.