0

I'm new to Concrete5 and have found a ton of information on adding contact forms, but only to the editable area of the page.

What I need to do is get a form into my page template. It's simply a name+email+submit button form to appear on every page for that template. On submission, a 'thanks' message... that's about it!

I've tried copy/pasting the code outputted into the page content to my default.php template but no luck with that. Thanks in advance for any help.

splscs
  • 61
  • 2
  • 7

3 Answers3

2

You should create a (global) editable area in the template, and then add a contact block to it just as you would otherwise.

E.g.:

<?php
$a = new GlobalArea('Contact Form');
$a->display();
?>
James S
  • 3,355
  • 23
  • 25
1

I agree with the other answer here... it's not worth the trouble to re-create a "hard-coded" contact form in your theme if you already have all the code working as a block. Here's a third technique you could use to achieve that -- you can hardcode just one block instead of the entire stack, like so:

<?php Block::getByName('My Global Contact Form')->display(); ?>

Put that code in your theme's template, and then add the contact form block to a stack in the dashboard (any stack, doesn't matter -- I usually create one stack of "global content" in my sites that I put all of these "hardcoded" blocks into). Then after you've added the block to the stack, click on the block and choose "Custom Template" from the popup menu. Then enter the block name into the field there (in this example, it would be "My Global Contact Form", without the quotes). Finally, click the "Approve Changes" button at the top of the stack.

Jordan Lev
  • 2,773
  • 2
  • 26
  • 39
0

You could approach this a couple of ways, but one way is to create a stack that has an contact form in it. Then, take the name of that stack and add it to your template.

So if the stack is called "Global Contact Form", then you could add the following to your template:

$stack = Stack::getByName('Global Contact Form');               
if( $stack ) $stack->display();
tofraser
  • 106
  • 1
  • 8