Jump to content

A single page site using PW?


poochandy
 Share

Recommended Posts

Hi,

I am a newbie to programming and I am developing this site for a client of mine(WIP) : http://greenpantry.in/test820fcec/

It is a single page site, where the content is divided into sections. I want to know if it would be feasible to use Processwire to manage the content of the site.

From what I have read, processwire's templating system is based on pages. I want to know if the client will be able to edit each section individually from the admin panel, as I feel creating a single long template for the page will be kind of messy. 'our platters' and 'gallery' are the two sections they want to be able to update.

Btw PW looks so fresh and this is probably a trivial thing to execute. I just wanted to be sure it was possible before i dive in. If this is possible, any pointers as to where I can start will also be very helpful as I am just now beginning to go through the docs/videos.

Thank you!

  • Like 1
Link to comment
Share on other sites

Hi there, welcome to the forum!

This is easily achievable in ProcessWire. In PW, what are called pages, are not really pages. They are, more or less, what are called nodes in other CMSs. You can organize your content on the tree the way you want. In your website, would make sense to organize it just like in any regular website (about, why, gallery, menu, etc...).

Then you call all the information from the homepage template. For this, you call the fields of individual pages like this:

$pages->get("name=about")->body.

So do, for instance:

$about = $pages->get("name=about");
$gallery = $pages->get("name=gallery");
$name = $pages->get("name=menu");
$why = $pages->get("name=why");

and then use $about->body, instead of $page->body

<div id="about"><?php echo $about->body; ?></div>
  • Like 3
Link to comment
Share on other sites

Hello there, and welcome to the forum!

What you're describing there sounds like something PW handles very well. You could, for an example, create all those sections as pages in PW and have one template file render content for all the others.

Here's a post about somewhat similar concept: http://processwire.com/talk/topic/821-question-understanding-templates%E2%80%93advanced-templating/#entry6999. This way you'd create a template file for all individual sections (assuming that they actually have different markup & fields each) and then at some point, index / home page probably, render them all.

Please note that I haven't done anything like this myself, but the concept doesn't seem too difficult - I'm sure others will be able to provide more helpful examples and educate us both about more sophisticated ways for achieving this result.

... actually, this sounds like a good idea for a nice little tutorial if anyone has some extra time ... :)

  • Like 1
Link to comment
Share on other sites

Seems that @diogo beat me to it. That's what you get for multitasking..

Anyway @poochandy, as you can see there's more than one way to do it. Dig in and don't hesitate to ask if you get stuck! :)

Link to comment
Share on other sites

You could also create various templates for the sections, and create them as pages underneath your parent/home. The php template would be just the section html markup with some content from the page.

<section>
   <h2><?php echo $page->title; ?></h2>
   <?php echo $page->body ?>
   <img src="<?php echo $page->image->size(100,100)->url; ?>"/>;
</section>

Then in your top page (home) php template you'll be able to render them out simply with something like:

foreach($page->children() as $p){
   echo $p->render(); // will render the above
}
  • Like 3
Link to comment
Share on other sites

I built a single page site on ProcessWire and found it very well suited. I used the method of creating pages, then include()ing each in the index file.

The important step for me in this was caching - without it the site would have performed too poorly. I set each template to cache for 24 hours and set the expiration setting to "Clear cache for the saved page and parents (including homepage)". With that the site loads quite quickly.

As with any single page site there were other things to consider - SEO, deep linking - but those aren't specific to ProcessWire. Shoot me a private message if you would like some more info about how I ended up addressing those issues.

Good luck!

(Oh, if you want to check out the site I built, it's at http://agencypja.com)

  • Like 2
Link to comment
Share on other sites

Another option here is to place all the fieldtypes into one template and use FieldsetTab pairs so that input fields get distributed onto different tabs in the page editor and it stays nice & tidy. For better undestanding see the picture in the first post. Then you could have all the fields accessible in your template like this: $page->fieldname.

I think this method is pretty neat provided you cache the page. The drawback here is that your site becomes less modular and you can't unpublish or substitute one page (section) with another as simple as with regular approach. But sometimes all you need is simplicity.

Edit: And if repeated elements of your page are uniform and their number is not supposed to be large, you could use repeater fieldtype for better user experience.

Cheers.

  • Like 1
Link to comment
Share on other sites

I am floored by the response here. I get the concept now but it is going to take me sometime to process everything and weigh the options :). I will post back the results once I have tried them and also if I have any doubts.

Marking the thread as solved. Seriously, you guys are great..

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