Forum
Add Form Template to a Page Template
Hi, Is there away to select a form template already created and used else where and dynamically add it to a page template?
My client has page templates created by me to create there web content. They would like to add forms to them. Is this possible?
Cheers
Yes. Using template includes.
Includes One template can be included inside another:
At runtime, the included template is inserted before any further processing is done. It’s as if the inner template was always part of the outer.
The path is relative to the perch/templates directory.
https://docs.grabaperch.com/docs/templates/includes/
Hi Robert, Can this be done dynamically?
There is a function to render templates at runtime. But it only works with content, not blog, events and others. I didn't get a chance to read back through this post so I may have missed something with my answer. Ask again if I did... :)
I have a page template that the user can use to create new pages.
I also have several forms in the template/forms. They use would like to use any of these forms on on any of the page templates. Is this possible?
I think it could.
There's a few of ways I can think of :
1) Have a content region in your page template called 'Form' and let the client choose their desired template from the form templates you've created (the form templates would need to be stored in perch/templates/content).
But, I don't like the idea of clients having to choose region templates. I think this because I try to avoid requiring the client to perform anything other than the simplest tasks, plus the Content template list is likely to have quite a few templates in it that may confuse (though remember you can hide them from the list by naming them beginning with a _. Eg '_template.html).
So how about this idea:
2) Create a content region in your page template above called 'Form' as described above and use perch_content_create to assign to it a template that contains all of your forms. You could allow the client to choose which form (if any) they would like to show on that page by using a select list, like this:
3) Or you could do similar to 2) but use Perch blocks
Many Thanks Folks. Your the best!