|
Generally you do not need to have an entire template group for the forms. There are many ways that forms can be set up, depending on how you build out the different URLs on your site. Here’s three ways to do it.
Method 1
If you are okay with the word “form” appearing in the URLs for your forms, you could just create one template that you link directly to for all forms. This is the simplest way to do it.
URL example: http://example.com/site/form/resume
{!-- Template Group: site --} {!-- Template: site/form --} {exp:proform:form form="{segment_3}"} ... paste in sample template contents of the proform:form tag ... {/exp:proform:form}
But you might not want to set things up like that, as the URLs are a bit weird with that setup. The cool thing about this method is that you don’t have to do any additional template editing when adding new forms. Just link to them and they will load correctly.
Method 2
Another way is to use an embed template. I usually put this in a forms template group, but you could put it in a global or site template group.
URL example: http://example.com/jobs/application
{!-- Template Group: jobs --} {!-- Template: jobs/application --}
... other template code ...
{!-- pull in the shared template which is used for all forms --} {embed="forms/_basic" form="resume"}
... other template code ...
{!-- Template Group: forms --} {!-- Template: forms/_basic --} {exp:proform:form form="{embed:form}"} ... paste in sample template contents of the proform:form tag ... {/exp:proform:form}
Method 3
The last way to do it is using a custom field. This is how we do it with most of our own sites.
Basically what you would do is create a new channel field to allow you to enter the form’s name for each page. Normally it would be set to be blank, but on the pages where you want a form to show up you would specify the form’s name in that field. You can use the DT-ProForm-Select fieldtype to provide a dropdown of available form names, or use SP Table Select, or just use a plain text field.
After you have that setup, you would add code in the template used to render each page. This is great if you are already using a single template for all your pages. For example, we use Structure a lot, so this works really well for us. You could also do something similar by passing the form name field to a footer template or other embed, which you then always include in all your other templates.
Assuming that this layout template is named layouts/pages and the field for specifying the form is named “pages_form_name”, we would do the following:
URL example: http://example.com/jobs/application
{!-- Template Group: layouts --} {!-- Template: layouts/pages --} {exp:channel:entries ... params here ...} {if pages_form_name}{!-- if a form has been selected, include the shared template --} {embed="forms/_basic" form="{pages_form_name}"} {/if} {/exp:channel:entries}
|