spos Posted November 13, 2012 Share Posted November 13, 2012 I'm trying to build a fairly simple site as an intro to processwire. Currently on my to-do list is to have an "our customers" page with a list of testimonials, and also to have a random testimonial snippet picked from this list in a sidebar on various other pages. So, I created a repeater field "testimonials" comprising testimonial_body, testimonial_summary and testimonial_name (the testimonial_summary is just a few choice words for the sidebar). Created a template "testimonial_list.php" and assigned the testimonials repeater field to it then made a page "our-customers" and gave it the template "testimonial_list". So, I've got an /our-customers/ page that lists the testimonials: foreach($page->testimonials as $testimonial) { echo "<blockquote><p>{$testimonial->testimonial_body}</p>"; echo "<small>{$testimonial->testimonial_customer}</small></blockquote> "; echo "<hr>"; } All good so far, but now I'd like to add pagination. However, after reading the selectors and pagination API docs I'm afraid I have no idea how to proceed. Should I even be using repeater fields for this? They weren't enabled by default so I'm thinking perhaps I should be using a separate page for each testimonial. I'm having a hard time figuring out how pages, templates, fields relate to each other. Link to comment Share on other sites More sharing options...
diogo Posted November 13, 2012 Share Posted November 13, 2012 Should I even be using repeater fields for this? They weren't enabled by default so I'm thinking perhaps I should be using a separate page for each testimonial. I'm having a hard time figuring out how pages, templates, fields relate to each other. You are thinking well here. Repeaters were created for a small number of repetitions. For a less predictable amount that justifies paginating would be better to use normal pages. In your case, you would have a page "testimonials" as a child of "our customers" and each children of "testimonials" would be one testimonial. The template for those pages would have the fields that you put on the repeater. foreach($pages->find('template=testimonial') as $testimonial) { echo "<blockquote><p>{$testimonial->testimonial_body}</p>"; echo "<small>{$testimonial->testimonial_customer}</small></blockquote> "; echo "<hr>"; } edit: It's also good to add that you are not forced to create a template file for all templates. In the case of the testimonials pages, if you are not planning to display them individualy, just create their template without a corresponding file, and their URLs won't be accessible in the browser. 2 Link to comment Share on other sites More sharing options...
MarcC Posted November 13, 2012 Share Posted November 13, 2012 I tend to use repeaters for things like board seats, where the number is typically limited to < 30 or so, but may change slightly from time to time. Link to comment Share on other sites More sharing options...
spos Posted November 16, 2012 Author Share Posted November 16, 2012 I've been away from a few days and only just came back to this but thank you both, I've been having a play this afternoon and the concepts are falling into place. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now