Jump to content

Using Repeater Items on Different Page


vwatson
 Share

Recommended Posts

I'm creating my first site with PW. I've seen several posts on this and I think I'm doing it the same way, but I can't make this work.
 
I have a repeater set up on a news page. The items display on that page correctly. I also want some of the items from the news repeater to display on the home page. (I'm going to use a checkbox in the repeater to determine which ones, but I can't get any of them to appear right now).

The $pages->get() appears to be returning the correct page, but nothing is displayed. I've used the page name and ID in the get().

Code on the news page works correctly:

        <?php
        foreach($page->news_items as $news) {
          echo "<div class='news'>";
          echo "<h2>{$news->heading}</h2>";
          echo "{$news->body}";
          echo "</div> <!-- news -->";
        }
        ?>

Code on the home page that DOES NOT work:

This code never gets into the foreach loop. The echo "news" line is never printed.

No idea what I am missing. :(

        <?php
          $newspage = $pages->get("/union-county-fair-news/");
          echo $newspage." page";
          foreach($newspage->$news_items as $news) {
            echo "news".$news;
            if ($news->show_home_page == 1) {
              echo "checked";
              echo "<div class='news'>";
              echo "<h2>{$news->heading}</h2>";
              echo "{$news->body}";
              echo "</div> <!-- news -->";
            }
          }
        ?>
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...