Jump to content

Recommended Posts

Posted

Hi there,

I have a single page website. This single page website has a section that includes posts that have their own content already displayed on the page.

What do you recommend, should it be best to maintain the repeater structure or should I make this section based on pages?

(you can think of this like a blog, but the content is already within the main page, thus making it a single-page website)

Thanks in advance ;)

Posted
What do you recommend, should it be best to maintain the repeater structure or should I make this section based on pages?

let it be pages. easier to maintain, better performance (in case there are a lot of articles), accessible for future development of your site.

Posted

let it be pages. easier to maintain, better performance (in case there are a lot of articles), accessible for future development of your site.

But how can I get the fields within the pages to display them on the single-page (the only page on the site)?

Posted

It is easy to get content from other pages in PW, but the actual method will depend on your needs. This is one example that allows you to echo out the body fields from all the child pages that match a given selector.

foreach($page->children(selector_to_get_specific_children) as $content_for_page){
    echo "<p>$content_for_page->body</p>";
}

You could also loop through any other pages you want be using a selector like this:

foreach($pages->find(selector_to_get_pages) as ....

Does that make sense?

  • Like 1
Posted

let's say you have the following structure:

- mypage

-- post 1

-- post 2

-- post 3 etc.

a post consists of a title and a text (to keep it simple). your goal is to display all content (title and text) from the posts on "mypage". that's pretty easy:

1. make a template "post" (it doesn't need to have a template file. it's just for holding the fields) with a title and a text field. assign it to your post pages and fill with content.

2. make a template "my page". assign it to mypage. from this template you loop over the child pages ("post") and retrieve their content. for example:

<?php
foreach($page->children as $post)
   echo "<h1>{$post->title>}<h1>";
echo "<p>{$post->text>}<p>";  
?>

that should to the trick.

EDIT: adrian was quicker. And sorry for the formatting of the code (which is not tested).

  • Like 2
Posted

Oh, yeah!! I totally forgot the "children" variable!

Thanks guys, this is exactly the kind of enlightenment I needed, of course it makes sense :P

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
×
×
  • Create New...