We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Problem, Runway

Suggestions on approach

I am looking for some suggestions on a approach for a dual carousel on a site I am working on.

Due to how I wanted to the element to work, I ended up making two carousels powered by javascript that are linked, so when one is triggered to the next slide, they both transition. When I came to building this I suddenly realized I didn't quite know the best solution to keep this easy to manage. Naturally I thought of splitting the two into two templates, but that would mean two different areas to which content needs adding. It may be that I just need to re-think how it works and simplify it for the sake of building in into Perch and having it easily manageable from one template, BUT I just want to see if any of you have any ideas.

Because my content editor will be adding one image, and one testimonial (text), ideally this needs to be in one template to make the process nice for them. If I had a template with just the image and text, is there then anyway to somehow split the content so one part, i.e. the text goes to somewhere in the template and the image to somewhere else? There would be multiple items added both containing one 'text' and one 'image' field.

Mathew Doidge

Mathew Doidge 2 points

  • 3 years ago

Sure, you can output the content of a region as many times as you need throughout the page, and use different templates for each output. So you might do something like:

<?php 
// first carousel
perch_content_custom('Carousel',[
"template"=>"_first_carousel_template.html"
]);

// second carousel, same content, different template
perch_content_custom('Carousel',[
"template"=>"_second_carousel_template.html"
]);

Legend Shane, why didn't I think of this! I really need to have words with myself. Thank you kindly.

Would there not be a performance benefit to using perch_content_custom to get the data with "skip-template" then just render the template twice? That way you're not fetching the data twice?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Probably not enough to make it worth it - unless you were in a pinch.

Ok. I have found with an older Perch site that pages with a longer history (many edits over time) seem to suffer from a load time lag when using perch_content_custom to the point that I had to implement a level of caching that wraps the native perch_content_custom with memcached. So I would have assumed that avoiding the two perch_content_custom calls would have been seen as beneficial. At least in the long run.