Forum
How do I display the content from one template in another
I have a template that is set to allow multiple items. I have a "reservation button" that is set to be shared across all pages. As each item is created in perch it must have a reservation button. If I use an include, it includes the reservation-link.html template, but that's not what I want. I want the html output of the reservation-link.html.
I want the output to display the button within each listing. Here is a link to the page so you can see what I mean. Each vehicle has a link to the reservation system. That link is a shared region so I don't want the user to have to fill in the same information each time they add a vehicle. How can I accomplish this?
You can use perch_content_custom to output different templates for the same content
https://docs.grabaperch.com/docs/content/perch-content-custom/
I don't understand why you would have a reservation button set as a shared region.
The button is set as a shared region because it's the same content (a link to the reservation system) used in several places. IE: the top of every page, the footer of every page and listed with each vehicle. Did you view the page? That would make it very clear.
So, if I had 17 vehicles all linking to the reservation system, that would be cumbersome to update each one should the link to the reservation system change( and that is a possibility). Also, if the link changes to an external system ( which it may in the future) That again becomes cumbersome to edit each spot in which the button is used.
Perch custom content won't work because I can't use that on a content template, can I? It doesn't seem to work when I do that. It does work on a master page, but not on the perch/content/templates/fleet-vehicle.html -- which is the template I used to create each vehicle listing on the referenced page.
My template is below. Using perch_content_custom returns 'reservation-link.html' to my live page.
I can't tell you how to architect your site, however the answer to your question is to use perch_content_custom, it may be that you need to make some changes to your original plan to be able to meet this requirement - that happens :)
Personally I would pass the link in as a template attribute, then you can set it in one place. It's not what shared regions are designed for so I don't think the plan you have in mind is going to work.
Thank you, but what do you mean set it as a template attribute? Can you point me in the direction where that is done and let me know how I should approach setting it up that way?
You can just pass in variables that you set up and then use them as you would use anything else
https://docs.grabaperch.com/docs/templates/passing-variables-into-templates/
Well, again, this approach assumes I know how to code in PHP, which I don't. Also, where does this code go? My master template? My content template? I'm sorry, but that explanation assumes a lot of knowledge I just don't have. How is it adjusted to fit my circumstance? I really don't understand all that code. So sorry, I don't mean to be difficult, it's just that without programming knowledge the code below is a foreign language for me.
Perch support isn't here to coach you through building a site or to provide tailored solutions to your specific issues. If you're not comfortable with the level of PHP needed to build your solution then you'll need to find someone else to help you with it.
We can point you in the direction of what's available in Perch and help fix issues you're having with the software, but we can't provide every customer with unlimited development consultancy on their project for free.