Jump to content

Tutorial: Approaches to categorising site content


kongondo

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.

Cheers!

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

   -Year

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

http://processwire.com/talk/topic/3325-filter-results-via-multiple-dropdowns/

http://processwire.com/talk/topic/2491-skyscrapers-profile/

http://processwire.com/talk/topic/1526-selectors-get-architects-from-city-buildings/

http://processwire.com/talk/topic/571-simple-drop-down-search/

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

Hi

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?

Quote

Thanks

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

<?php

$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; ?>

...prints...

Top of the range SUV

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

Instead...

<h1>Index of all cars</h1>

<?php

$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; ?>

prints...

Top of the range SUV

MAKE: Land Rover
MODEL: Range Rover
YEAR: 2015
COLOUR: White
SEATS: 5
TYPE: SUV

 

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:

Quote

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