Jump to content

Tutorial: Approaches to categorising site content


Recommended Posts

Are you gone crazy? :P

And even with colors!

That's exactly what I asked myself! Editing using the forum editor was a pain! And with such a long post, it was going all crazy on me! Next time I'll post on my site ;)...which I am starting soon anyway.

Edit: I've just seen a Word to BBCode macro...should have used that; would have saved me some pain!

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

Kongondo, thanks very much for taking the time to make this post. It really puts the tree organization into perspective. It also goes the extra mile and walks you through the process of doing it and making it easy on the eyes.


Link to comment
Share on other sites

Awesome Kongondo! I haven't gone through the whole thing yet, but am printing out so I can read in more detail. But it's clear you've put a lot of great work and thinking into this, Thanks! I can't wait to read it in full. 

  • Like 1
Link to comment
Share on other sites

I am seeking some advise on option 2. Simple Multiple Categories for my structure.

Basically I have several locations that will list employees. Each location will have different employees.

Each employee will have at the minimum a First Name, Last Name, Title, Department, Age, Image, Year.

Employee Fields would be: First Name, Last Name, Title, Age and Image which will be unique to each employee.

Department: An employee may belong to one department and in rare cases maybe more. A department will have multiple employees, 

the departments will vary per location.

Year: Same as department

The most important part that I need to confirm is that on the front end, the user will need to be able to search the employees by first name, last name, department, year and a range of ages IE  Low____ High____. Ideally the first name and last name will need be input fields and the rest could be a drop down.

Location 1

  - Employee

     -- John Doe

     --Jane Doe

  - Department

    -- Confused Department

    --Even More Confused


    -- 2013

    -- 2014

Location 2

    " "

Location 3

   " "

So my question is am I on the right track and is it possible to create the search functionality that I would need with the above layout? Thanks in advance for any tips, advise, recommendations or silence :)

Link to comment
Share on other sites

You are on the right track (looked at this quickly). In those "rare cases" you mention you will want to use multiple page reference fields, of course. As for search functionality, yes that can be done. Look at the Skyscrapers site/profile to get you started.

dl profile: http://mods.pw/3T

example: http://processwire.com/skyscrapers/

If you have more specific questions regarding "search", I'd suggest opening a new thread tailored to those questions so that they can be picked up quickly/easily.

Edit: Added useful links





  • Like 1
Link to comment
Share on other sites

  • 6 months later...
  • 1 year later...
  • 4 months later...
  • 6 months later...

Should the pages created as categories and subcategories be configured/kept as unpublished or hidden (or perhaps both)? Or for this to work, should they be both published and viewable?

My main concern is that these categories (ie: Year, Model, Type, etc), being that are just PW Pages, all are directly children of  Home (root), and so, are at the same  level of depth than other PW Pages that may be "real" pages (ie. Cars, About, Contact).

Then, the "problem" would be: iterating over the children of Home ($page->children()), for example, to display a first-level nav, will eventually show the main categories, if those are unhidden. Right? 

PS: great tutorial, it really helps to clear up a lot of things for PW newcomers. It also helps to think better the relation between PW concepts (products as pages, categories as pages, etc) and general web design/development. Thanks for sharing.

Link to comment
Share on other sites

They don't have to be configured as hidden/unpublished. It all depends on your use case. You may want to show them (i.e.. Year, Model, etc) as menu sub-dividers for instance. Other than hiding them, If you don't want them to show up in menus, you could also remove them from the returned PageArray prior to outputting your menu. 

  • Like 2
Link to comment
Share on other sites

  • 6 months later...


I read and re-read this great tutorial to learn how to set-up my templates. However, I have no clue how to get url working correctly in the case of using pages field as category.

In forum's posts, I saw many times "kind-of" similar code using urlsegment, but I'm still not sure to understand the basics. Which of my template should be urlsegment activated? In which template I put this code?

I was wondering if this wiki page was an example step-by-step? Does someone have still access to this?



Link to comment
Share on other sites

Read this @mel47 :  https://processwire.com/docs/tutorials/how-to-use-url-segments/


And you can find the wiki url under archive.org :  https://web.archive.org/web/20150422040149/http://wiki.processwire.com/index.php/URL_Segments_in_category_tree_example


An interesting thread:  


Edited by flydev
  • Like 2
Link to comment
Share on other sites

  • 7 months later...
On 17/05/2013 at 2:55 AM, kongondo said:

Example code to access and show content in Simple Multiple Categories model

$cars = $pages->find("template=car-template, limit=10, colour=red, year=2006, seats=5");
foreach ($cars as $car) {
echo $car->title;
echo $car->year;
echo $car->colour;


This prints an ID of the page being referenced i.e.

<h1>Index of all cars</h1>


$cars = $pages->find("template=car-entry");
foreach ($cars as $car): ?>

<h2><?php echo $car->title; ?></h2>

<p>MAKE: <?php echo $car->make; ?></p>
<p>MODEL: <?php echo $car->model; ?></p>
<p>YEAR: <?php echo $car->year; ?></p>
<p>COLOUR: <?php echo $car->colour; ?></p>
<p>SEATS: <?php echo $car->seats; ?></p>
<p>TYPE: <?php echo $car->type; ?></p>

<?php endforeach; ?>


Top of the range SUV

MAKE: 1069
MODEL: 1078
YEAR: 1079
COLOUR: 1054
SEATS: 1057
TYPE: 1061


<h1>Index of all cars</h1>


$cars = $pages->find("template=car-entry");
foreach ($cars as $car): ?>

<h2><?php echo $car->title; ?></h2>

<p>MAKE: <?php echo $car->make->title; ?></p>
<p>MODEL: <?php echo $car->model->title; ?></p>
<p>YEAR: <?php echo $car->year->title; ?></p>
<p>COLOUR: <?php echo $car->colour->title; ?></p>
<p>SEATS: <?php echo $car->seats->title; ?></p>
<p>TYPE: <?php echo $car->type->title; ?></p>

<?php endforeach; ?>


Top of the range SUV

MAKE: Land Rover
MODEL: Range Rover
YEAR: 2015


Great guide @kongondo has been very helpful indeed this morning :) thanks.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Thank you kongondo, very helpful!

In the first model (single Category) you create for each Department a different template. Why?
Isn't that a bit overkill if you have e.g. 30 Departments  (If any department-template have identical fields)?
Why not use one template for all departments and filter another way?




Link to comment
Share on other sites

Well it is more a example of finding the right model to store things....if you would have 30 departments you would possible choose methode 2 or 3 for storing this kind of things...but

the first model describes the most simpel way to store 1:1 connections - one member : one department....

Another thing that is here important this models are all show the usage of the pagetree in ProcessWire so a editor with a "small" company with "normal" amounth of departments could easy and fast manage his content....and we could fast get the data on frontend.

On the Template side of life there you could read again on this from kongondo:


You have the choice of creating one template file for each category template as well. I prefer the method of using one main template file (see this thread). You could do that and have all Departments use different templates but a single template file. In the template file you can include code to pull in, for example, the file “technician.inc” to display the relevant content when pages using the template “Technician” are viewed.

These are just the basic examples for beginners - if you manage complex data and complex editing you could or better will use of ListerPro or even a own admin dashboard, hinding content from the pagetree that confuse the editors and make other strange but always possible things for managing complex content and at the same time give your users a good ui for editing this content.

regards mr-fan

  • 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
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By jds43
      Hello, I'm trying to list the categories, on the front through select options, that have been selected by page reference field (multiple pages PageArray) on the child pages.
      Things to Do (would only display three, six, seven, nine in select)
      -thing one (-category three, -category nine)
      -thing two (-category six, -category seven)

      Lodging (would only display one, two, three, four in select)
      -lodging one (-category one, -category two)
      -lodging two (-category three, -category four)

      Dining (would only display five, six, seven, eight in select)
      -dining one (-category five, -category six)
      -dining two (-category seven, -category eight)
      Categories(hidden page)
      -category one
      -category two
      -category there
      -category four
      -category five
      -category six
      -category seven
      -category eight
      -category nine
      -category ten
      $categories = $pages->find(1129)->children('include=hidden'); foreach($categories->references('category') as $ref) { echo $ref->title; } This selector isn't working, but it seems 'references' would be helpful. I've never used it before, so I'm not sure how to employ for this.
    • By stanoliver
      Good morning everyone!
      I have a growing number of posts about cars, bikes, airplanes, etc. 
      The following code (below) just works fine and returns only the posts of the category=cars as I desired together with pagination.
      In my url I have for example /categories/cars/car1 or /categories/bikes/bike1
      I do want to filter my posts not only with ... category=cars ... but also with category=bikes or category=airplanes and at best:
      If my url is /categories/bikes/ then ... category=cars ... should be overwritten or replaced by ... category=bikes ... 
      If my url is /categories/airplanes/ ... then the filter should be ... category=airplanes ... (I know a work around by creating almost identical templates where I could just change the "category=cars" part of my code but that's comes of a prize by repeating a lot of identical code and is not a good habit). In the documentation I read something about the "has_parent" selector but I could not get to work it related to the urls mentioned above.
      <?php foreach ( $results = $pages->find('id>1, template=templateblogpost, category=cars, limit=5, sort=-postdate') as $post 😞?> <!-- Blog entry --> <div class="g8-card-4 g8-margin g8-white"> <!--<img src="/g8images/bridge.jpg" alt="Norway" style="width:100%">--> <div class="g8-container"> <h3><b><?= $post->title; ?></b></h3> <h5>Datum: <span class="g8-opacity"><?= $post->postdate; ?></span></h5> </div>   <div class="g8-container"> <p><?= $post->posteditor; ?></p> <div class="g8-row"> <div class="g8-col m8 s12"> <p> <a href="<?= $post->url; ?>"><button class="g8-button g8-padding-large g8-white g8-border"><b>Details lesen &raquo;</b></button></a> </p> </div> <div class="g8-col m4 g8-hide-small"> <!--<p><span class="g8-padding-large g8-right"><b>Comments &nbsp;</b> <span class="g8-badge">2</span></span></p>--> </div> </div> </div> </div> <!-- END BLOG ENTRIES --> <?php endforeach; ?>   <? echo $results->renderPager(array( 'nextItemLabel' => "rückwärts", 'previousItemLabel' => "vorwärts")); ?>
    • By adrian_gp
      Hello everyone,
      I'm new in this forum and my english is not perfect so sorry for the mistakes.
      I have an Blog Project and i will use categories. 
      Here is the structure:
      Blog -> displays all the Blogposts (template=BlogPage) Post-Name -> display the specific Post (template=BlogPost) Categories -> not visible in the menu (template=CategoriesPage) Categorie-Name -> not visible in the menu (template=CategoriePage) For your information:
      (BlogPost) every blogpost has its own page (BlogPost) in Admin i can select the categorie per Field -> SelectMultiple Pages (Checkbox) (fieldname=categories) (Blog) displays all the BlogPosts and all the categories under the ParentTemplate CategoriesPage, which also have their own side Now the Problem:
      On Blog -> I would like to click on a category and only see the post that has this category checked in the BlogPost.
      CategoriePage -> what do I have to insert there to show only the specific posts which use the checked categorie?

      Let me know if you need more information

      Thanks for your support
    • By zaib
      I've a page "blog" which have child pages (blog posts). Right now I've 11 pages (blog posts) and I'm fetching all the posts in my "blog" pages which displaying fine, Issue is only 10 results are showing this is how I'm fetching
      $entries = $pages->find("template=blog-entry"); foreach($entries as $entry){ <a href='{$entry->url}'>$entry->title</a> }  
    • By Outcydaz
      I have a site structure as follows
      -- Shirt One
      -- Shirt Two
      -- Shoe One
      -- Shoe Two
      -- Spring Summer
      -- Fall Winter
      Each page has a 'category' page field.
      I'm trying create a navigation that shows only the child categories as follows:
      -- Spring Summer
      -- Fall Winter
      -- Spring Summer 
      -- Fall Winter
      When Shirts -> Spring Summer is clicked i'd see only spring summer shirts. Same for Shoes, you'd only see Spring summer items for shoes.
      Help please.
  • Create New...