Forum
Template Handlers?
Hey,
As far as I'm aware, template handlers are for output only, would that be correct?
What I'm trying to achieve is having a template handler to automatically generate inputs based on external data. So say I wanted x amount of text inputs, I'd want the template to automatically render that many text inputs. I thought I may be able to use a template handler, like so:
<perch:students>
<perch:student id="text" type="textarea" label="Text" markdown="true" html="true" editor="simplemde" />
</perch:students>
Would it be possible to make it so that the inputs could be rendered admin side, based upon how many students there are? Or is that not possible?
If so, would there be another way to achieve this? Any advice on best practice for this?
Thanks!
Looks like a custom app, couldn't you achieve this without using a template? (PHP generation on the page)
Maybe I'm missing something?
It isn't a custom app, I want to be able to use it universally across content etc.
I don't think it's possible but wanted to just double check!
Ah sorry, I saw perch:students and assumed custom app.
Yeah as far as I'm aware template filters only apply for rendering the template content rather than on the edit page unfortunately.
Hi Ryan,
I think you can use a field type plus a template handler. The field type would be used for editing and the template handler's job would be to display the content on the frontend.
It's like the categories tags. What you put inside the tags are for frontend output only (e.g.
catTitle
). But you control the field in the edit form with attributes such asset="blog"
,max="4"
anddisplay-as="checkboxes"
.I think the same goes for
perch:related
tags.In a field type the function
render_inputs()
can output multiple fields.It sounds possible. Worth a try.