Jump to content

Creating Single Page layout with sections as child page


processwirefan
 Share

Recommended Posts

Hi, I am totally new to ProcessWire and really love it! Specially due to the following reasons:

  • Uses raw PHP for template engine, no Smarty (too heavy) or Twig (I like twig) by default, so no extra learning curve.
  • Easily themeable similar to Modx (but kinda complicated with slow Admin Panel) or Kirby CMS (similar to Stacey CMS but commercial), unlike other CMS like WordPress that impose you with predefined structure.
  • Flexible custom fields (in WordPress it was still kinda painful to use with Advanced Custom Fields plugin, having developed several themes and plugins).
  • Backend admin panel is simple and clean, no learning curve.

Thank you Ryan for creating this wonderful CMS! This was the dream CMS I was looking for and regretting for not have found this gem earlier.

I am trying create a standard one page website with different sections, for example, similar to:

http://tiltingpoint.com

and would like create it with the following page and subpage (section) structure in ProcessWire:

Home (main page)
- Intro section (intro text with a background image, title not necessary)
- About section (title and text)
- Team section ( display 3 column layout with 3 staff images and text intro below)
- Clients section (will display 5 client logo images)
- Gallery section (gallery with 3 row x 3 column images that fires lightbox)
- Contact form section (a contact form with company address)
 

And here is what I am trying to do:

  1. Each section (subpage) will have different custom fields from the others, it's not going to have standard Title and Textarea fields.
    UPDATE: This is default ProcessWire feature
  2. Each section will use it's own template file, so a user just have to enter the required information (text and image), without any HTML structure because it will be predefined inside the template file. I see that the following API command can be used: 
    pages->get("/about/press/")->children();
    

    but it doesn't seem it will load the default template files assigned to them. Or do I have to manually check the assigned template file and insert them into the code?

     
  3. The order of section display should be easily reordered by the user if possible (trying to prevent editing the Home template file directly).
    UPDATE: Reordering is possible: http://processwire.com/videos/using-the-image-thumbnail-plugin/
  4. The section (subpage) shouldn't be directly accessible by URL, should return 404 not found instead. Looks like setting status to unpublished will work, is this the only option?
     

I am trying to avoid creating all the fields for Home page alone without subpages, because it can be overwhelming to enter all the information at once from a single input page. After searching the forum, the closest thread I've found was:

http://processwire.com/talk/topic/4843-pages-vs-repeater/

But I think it still doesn't address the problems I am trying to solve above (I might be wrong). Wondering what's the best way to approach this problem? Should I Include all the section templates from the main Home template (does it even make sense) or is it possible to pull this off from ProcessWire admin panel somehow?

Thank you!

David

--------------------

UPDATE: Looks like the only things left to be solved are 2. and 4. Any tips?

Link to comment
Share on other sites

The section (subpage) shouldn't be directly accessible by URL, should return 404 not found instead. Looks like setting status to unpublished will work, is this the only option?

I think you need something like this (direct page access redirects to the parent page):

if ($_SERVER['SCRIPT_URL'] === $page->url) {
	$session->redirect($page->parent->url);
	exit;
}

alternatively, if you would like to show a 404:

if ($_SERVER['SCRIPT_URL'] === $page->url) {
	throw new Wire404Exception();
	exit;
}
  • Like 2
Link to comment
Share on other sites

There you have it, geeber and titanium just answered to the missing points. Building on top of that, your homepage code wouldn't be too different from this:

<?php
// header code

foreach ($page->children() as $child) $child->render();

// footer code
 

Couldn't get much simpler than this, could it?

edit: titanium's method is perfectly fine, but if you're using the dev version you can use the method that Ryan describes here http://processwire.com/talk/topic/3551-small-tip-for-pages-that-will-be-used-with-render/

  • Like 2
Link to comment
Share on other sites

  • 3 years later...
On 02/12/2013 at 9:59 AM, titanium said:

I think you need something like this (direct page access redirects to the parent page):


if ($_SERVER['SCRIPT_URL'] === $page->url) {
	$session->redirect($page->parent->url);
	exit;
}

alternatively, if you would like to show a 404:


if ($_SERVER['SCRIPT_URL'] === $page->url) {
	throw new Wire404Exception();
	exit;
}

Totally just needed this, thanks :)

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