Jump to content

Extract Content From Repeater to another page?


quickjeff
 Share

Recommended Posts

Hi Guys, I am absolutely loving Processwire but need some assistance in a custom build. 

I have created a repeater for an internal page. I need to pull the data using GET or some other way to display the first five repeated sets onto my home page for my featured items section. 

Is this possible?

If so, any examples? Guidance?

Your help is much appreciated! 

Link to comment
Share on other sites

Mr. Bean!!! Had to use that pic, its classic!

- Diogo, I am having some issues. 

Here is the repeater I have on a template labeled bands.php

I need to pull the first 5 in the list.  The repeater is used to create a band event page for my client, therefore there can be as many as 30 repeated on this page.  I just want the home page displaying 5, the first 5 in the list. 

Any light on this?

<?php foreach($page->band_performance as $band_performances) {
    echo " <article class='4u special'><header><h2>{$band_performances->band_date}</h2>";    
    echo "<h3>{$band_performances->band_title}</h3>";
    
    if(count($band_performances->band_image)) {$image = $band_performances->band_image->getRandom();
	echo "<a href='{$band_performances->band_website_url}' target='_blank' class='image featured'>
	<img src='{$image->url}' width='368' height='300' alt=' '/></a></header>";
    echo "<p>{$band_performances->band_description}</p>";
    echo "<p>Charge: {$band_performances->band_cover_charge}</p>";
    echo "<p>Time: {$band_performances->band_hours}</p>";
    echo "<footer><a href='{$band_performances->band_website_url}' class='button' target='_blank'>More Info.</a></footer></article>";
  
} 

	
?>
Link to comment
Share on other sites

And you have to change $page to  the page you want. The example that I gave above would get the page by name, buy you can get it by ID also $pages->get(1654) besides other ways using the different selectors. The only info that I have from you about that page is the template. Assuming that that's the only page using that template, this should work for you:

<?php foreach($pages->get("template=bands")->band_performance->find("limit=5") as $band_performances) {
 

edit: get() returns the first page found that matches the selectors, while find() returns an array (pageArray) with all matches for the selectors.

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...