Jump to content

Recommended Posts

Posted

Hi guys,

I'm Lucas. I was wondering if you guys could give me a little hand with ProcessWire.

How can I setup a "tour dates" page for a band website and make it editable in the panel so the band members can easily add/edit dates?

Thank you in advance!

Warm regards,

Lucas

Posted

Edit: welcome! :)

First off, create a template tourdates and a template tourdate. Setup appropriate family construction in the template under "family" so that the tourdate template is only addable under the tourdates template.

Then you create a datetime field called tour_date_start. Add the field to the tourdate template. Setup a page called /tours/ with the tourdates template. Make sure you setup the field correcty under the details tab.

Create an couple of pages (basicly dates) under /tours/.

Create a file called tourdates.php and loop the content as following:

foreach ($page->children as $tourdate) {
echo $tourdate->title; // this is the title
echo $tourdate->tour_date_start; // this is your date
}

If you want to show them at another page, i.e. the homepage you can do the following:

$getTourDates = $pages->get("/tours/")->children(); // Get the parent and loop through these use the above example.

If you want to sort them by date turn on autojoin at the field page in the admin - it's under advanced. Then you can sort them by tour_date_start like:

$getTourDates = $pages->get("/tours/")->children(sort=tour_date_start); // Get the parent and loop through these sorted use the above example.
  • Like 2
Posted

Great answer Arjen. One correction though: autojoin is not required to sort by date.

And welcome Lucas!

Hmmm, I always assumed that to sort any field (except title) it has to be autojoined. Thanks for the info!

Posted
Hmmm, I always assumed that to sort any field (except title) it has to be autojoined. Thanks for the info!

This used to be the case but isn't anymore.

Posted

@ryan: On autojoin being a requirement for sorting you said:

This used to be the case but isn't anymore.

I guess the help text in the advanced section of field edit should be corrected then? Currently it's misleading.

If checked, the data for this field will be loaded with every instance of the page, regardless of whether it's used at the time. If unchecked, the data will be loaded on-demand, and only when the field is specifically accessed. Enabling autojoin also allows the field to be used as a key for sorting pages.

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
×
×
  • Create New...