[Support request] Element (or pattern) Shortcode

Home Forums Support [Support request] Element (or pattern) Shortcode

Home Forums Support Element (or pattern) Shortcode

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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,
    Shannon

    #2396091
    Ying
    Staff
    Customer Support

    Hi 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.

    #2396990
    Shannon

    Thanks Ying.

    So this is not possible via a hook or shortcode either?

    #2397034
    David
    Staff
    Customer Support

    Hi 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 Custom and in the field provide add : portable_hook

    Can’t say how gravity will deal with that, or whether the styles will load correctly. But thats about all we have

    #2397285
    Shannon

    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.

    #2397821
    David
    Staff
    Customer Support

    Is 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.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.