- This topic has 3 replies, 3 voices, and was last updated 3 years, 1 month ago by Elvin.
-
AuthorPosts
-
March 28, 2021 at 2:02 pm #1713259Thomas
Hello everyone and thank you for the help.
I coded a small contact form in PHP and inserted it utilizing Hooks and elements with GeneratePress. It works, however the only “issue” i have is that that content isn’t contained within the sites container. I know this could be fixed utilizing CSS, but i’d like to make it as “hands off” as possible for the end admins of the site. So i’m wondering if there’s a way to create custom blocks for gutenberg utilizing GeneratePress, or some kind of method i’m missing that this could be apart of?
Also a quick side question; in terms of GeneratePress it’s better to “code a theme” utilizing elements then directly into a child theme or is there even much of a difference?
edit: Actually my logic isn’t working by doing it this way…I guess i’d have to develop a plugin for it?
Thank you so much!March 28, 2021 at 3:36 pm #1713328LeoStaffCustomer SupportHi there,
So i’m wondering if there’s a way to create custom blocks for gutenberg utilizing GeneratePress, or some kind of method i’m missing that this could be apart of?
It would definitely require some custom coding to create your own custom blocks and I’m not sure if it’s worth the effort.
The contact page is set to full width in content container which is why the content isn’t within the container:
https://docs.generatepress.com/article/content-container/I feel like the best solution here is to use a plugin like Contact form 7 instead of creating your own.
March 28, 2021 at 3:40 pm #1713330ThomasYeah I guess sometimes its not worth going out the way to hand code stuff when something like CF7 would work just as well lol!
Thanks Leo.
March 28, 2021 at 7:06 pm #1713422ElvinStaffCustomer SupportHi there,
If I may, let me share a bit of food for thought:
There’s actually a way to insert custom PHP within gutenberg.
You can create a custom shortcode that allows you to create a portable hook you can place anywhere within the Gutenberg Editor.
We then create a shortcode to allow us to create portable hooks anywhere it’s placed.
add_shortcode('portable_hook', function($atts){ ob_start(); $atts = shortcode_atts( array( 'hook_name' => 'no foo' ), $atts, 'portable_hook' ); do_action($atts['hook_name']); return ob_get_clean(); });
Usage:
[portable_hook hook_name="my_custom_hook"]
You can use this shortcode within the Block Editor.
With this, we can utilize GP Premium’s Hook Element (for custom PHP) and hook them to our portable hook, in this example,
my_custom_hook
.But yeah, for your specific purpose, the best way is to just place a contact form block directly using plugins. 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.