Jump to content

Can PW do this?


Stardog
 Share

Recommended Posts

I like what I've seen from ProcessWire so far, and it seems a decent alternative to EE, but maybe not.

This is what I'm looking for:

Website Setup

  • Index Page
  • Blog Page
  • Portfolio Page

The Blog Page needs custom fields Title (text)/Body (textarea) for each item/post. This seems doable no problem.

The Portfolio Page needs custom fields Title (text)/Description (textarea)/Image (image) for each item/post. Again, seems doable.

The Index Page needs to take pieces from the blog/portfolio pages and display them in this kind of way:

<h1>Index Page</h1>

<div>
<h2>Recent blog posts (TITLE FIELD ONLY)</h2>
<ul>
<PW:ShowStuffFromThisPage page="blog" limit="10" sort="descending">
	<li><PW:title/></li>
</PW>
</ul>
</div>

<div>
<h2>Recent portfolio items (TITLE AND IMAGE ONLY)</h2>
<PW:ShowStuffFromThisPage page="portfolio" limit="4" sort="descending">
	<PW:title/>
	<PW:image/>
</PW>
</div>

And the Blog Page would have something like this:


<h1>Blog Page</h1>

<PW:ShowStuffFromThisPage page="blog" limit="10" sort="descending">
<div class="blog-post">
  <h2><PW:title/></h2>
  <PW:body/>
</div>
</PW>

Also, can I do a conditional to make the most recent blog post look different? Like:

<if blogpostindex > 1>

Use different template code

</if>

Link to comment
Share on other sites

Welcome to the forums stardog. Those are all very easy and basic stuff for Processwire. I'll translate your pseudo-tag examples to php (which PW uses as template language also):

<PW:ShowStuffFromThisPage page="blog" limit="10" sort="descending">
 <li><PW:title/></li>
</PW>
foreach ($pages->find("template=blog-post, limit=10, sort=-created") as $p) {
 echo "<li>$p->title</li>
}
<PW:ShowStuffFromThisPage page="portfolio" limit="4" sort="descending">
 <PW:title/>
 <PW:image/>
</PW>
foreach ($pages->find("template=portfolio-item, limit=4, sort=-created") as $p {
 echo $p->title;
 echo "<img src='{$p->image->url}' alt='' />";
}
<PW:ShowStuffFromThisPage page="blog" limit="10" sort="descending">
<div class="blog-post">
  <h2><PW:title/></h2>
  <PW:body/>
</div>
</PW>

Since blog-posts are probably children of "blog" page, then no need for template checking on selector:

foreach($page->children as $p) {
 if ($p == $page->children->first()) $class = 'first'; //this is for differentiation of the first post
 else $class = '';

 echo "<div class='blog-post $class'>";
 echo "<h2>$p->title</h2>";
 echo $p->body;
 echo "</div>";
}
  • Like 2
Link to comment
Share on other sites

Hijacking this post somewhat but have to say Apeisa that this is the sort of feedback which makes people want to commit to a piece of software!

The community here seems very strong and thoughtful and not at all arrogant. I have to say it bears some resemblance to the support from EE, from which I'm coming from and for an open-source product I think that's very impressive.

I was put off another similar open-source system because the founder was anything but helpful or polite or forthcoming with help. The documentation here is incredibly thorough and the people seem 'nice' (amazing how much of a difference that makes).

Anyway back to the post, am also coming from EE so anything that can help me get my head around the differences in the way things works is very welcome!

  • Like 3
Link to comment
Share on other sites

onjegolder: thanks for your kind words and welcome aboard. Very much appreciated. I agree, this is among the top communities around there. We all do our best to maintain the polite and helpful atmosphere here as we grow in popularity. People tend to follow each others behavior, and Ryan has set the exactly right course for our community.

It is also amazing how fast newcomers start contributing and help others.

  • Like 1
Link to comment
Share on other sites

onjegolder: thanks for your kind words and welcome aboard. Very much appreciated. I agree, this is among the top communities around there. We all do our best to maintain the polite and helpful atmosphere here as we grow in popularity. People tend to follow each others behavior, and Ryan has set the exactly right course for our community.

It is also amazing how fast newcomers start contributing and help others.

I agree! I think often it's about creating a professional, caring and stimulating environment and Ryan seems to have done a very good job.

  • Like 1
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...