Jump to content

Holder/Page Pattern


cssabc123
 Share

Recommended Posts

Hi, How do you implement a holder/page pattern in Processwire. The idea is simple. One page type manages the list view, and usually contains very little native content. The primary function of this page is to provide a list of its child pages, providing a brief summary for each one, along with a link to its detail view. A second page type will represent the detail view for any given child page, which will typically have a custom template and content fields that make up its identity. Think of it think like a news listings, image galleries, even a Twitter timeline.

Link to comment
Share on other sites

Hi cssabc123, welcome to the forum!

Very quickly and resumed because of time constraints:

- Holder

  - article 1

  - article 2

  - ...

//holder.php

foreach ($page->children as $article) {
    echo "<h2>{$article->title}</h2>";
    echo "<p>{$article->summary}</p>";
    echo "<a href='{$article->url}'>Read more</a>";
}
//article.php

echo "<h2>{$article->title}</h2>";
echo "<p>{$article->body}</p>";

I left lots of things out,like pagination, that you can read about here https://processwire.com/blog/posts/processwire-2.6.18-updates-pagination-and-seo/

But hope you get an idea.

  • Like 1
Link to comment
Share on other sites

Thanks a lot diogo! Just a follow up question.  that means the children pages are unpublished but still created. so if i had 100 child pages I need to create 100 pages? Any way to make only 1 page then dynamically create the detail from a database using Processwire?

Link to comment
Share on other sites

Not sure if I understand what you mean. You want to have the detailed content in a custom database, or...?

I'm not suggesting that you duplicate the pages, or something like that. Those are the children pages "detailed view", and they contain all the content.

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...