Jump to content

Building a tumblr-style website


aren
 Share

Recommended Posts

Hey guys,

I was wondering if it's possible to build a Tumblr-style website with ProcessWire. Sections/pages would be Article, Image, Video, Audio and Quote. But how can I get the posts from all of them (ordered by date as in a blog) in the homepage?

Many thanks for any help!

Link to comment
Share on other sites

Hi apeisa, thanks for such a quick reply! :)

So I don't have to include the templates "articles.php", "images.php" and so on.. in the code? 

Oh, and can you please tell me what the "render" in the code does?

Link to comment
Share on other sites

Hi apeisa, thanks for such a quick reply! :)

So I don't have to include the templates "articles.php", "images.php" and so on.. in the code? 

Oh, and can you please tell me what the "render" in the code does?

Each type of articles must have it's own template. "Render" makes output depending on different templates.

Link to comment
Share on other sites

$allArticles = $pages->find("template=article|image|video|audio|quote, sort-=created, limit=20");

foreach($allArticles as $article) {
  echo $article->render();
}

For crying out loud! How easy is this system! Only 3 lines of code. PW has spoiled us all! :)

Oh, and can you please tell me what the "render" in the code does?

In other words, render outputs those pages including their templates files markup (i.e. not just their field values). The one thing you need to be mindful of (if I remember correctly) is to construct the HTML in those template files (assuming they have HTML) properly so that your rendered pages do not end up with duplicate HTML elements where you should only have one-pair tags, e.g. <body></body><body></body>, head, etc..Only include the markup you need...

Edited by kongondo
  • Like 1
Link to comment
Share on other sites

To avoid any duplication kongondo is talking: In latest versions (not sure if in stable yet), you can do this:

$allArticles = $pages->find("template=article|image|video|audio|quote, sort-=created, limit=20");

foreach($allArticles as $article) {
  $templateFile = $article->template . "-teaser.php";
  echo $article->render($templateFile); // It renders the content with article-teaser.php, image-teaser.php etc...
}

There is of course multiple ways of doing that (I rarely output any markup in templates directly), but I think that would be nice way of doing simple tubmlr-style blog.

  • Like 4
Link to comment
Share on other sites

Nice! It didn't know you can do that. We definately need a markup guide and templating guide with different approaches. There are some great posts hidden in this forum. If only I could find some time to collect all that information.

  • Like 3
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...