kongondo

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

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
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 :)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Funny.... I've been digging this forum like hell and I stumbled on this one... just after I finished a car site LOL.

Still interesting and it seems I was on the right track from the beginning....

Great TUT

  • Like 1

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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?

 

 


 

Share this post


Link to post
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

Share this post


Link to post
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 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
      Shirts
      -- Shirt One
      -- Shirt Two
      Shoes
      -- Shoe One
      -- Shoe Two
      Category
      -- 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:
      Shirts
      -- Spring Summer
      -- Fall Winter
      Shoes
      -- 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.
       
    • By DarkwaveSurfer
      Hi,
      I'm total newbie for php and Processwire so be patient with me
      I'm trying to make a simple blog. 
      BLOG - list of all posts   (template: blog-list)
      -- Post no.1   (template: blog-entry)
      -- Post no.2   (template: blog-entry)
      -- Post no.3   (template: blog-entry)
      CATEGORIES   (template: categories)
      --  Jobs   (template: category)
      -- Technology   (template: category)

      Template for post "blog-entry" has Page field set to Multiple pages and input as Checkboxes. So it is posible to select CATEGORIES children pages via checkbox when editing blog post.
      This is how I show selected categories within blog-entry template for current blog post:
      foreach ($page->categories as $category) { echo "<a href='{$category->url}'>{$category->title}</a>"; } How do I show selected categories within blog-list template?
      I need list of all posts with their Title, body and selected categories from Page field checkbox. I managed to show title and body but not categories.
      This is my code so far:
      <?php echo "<h1>" . $page->get('headline|title') . "</h1>"; $entries = $pages->find('template=blog-entry')->sort('-created'); foreach($entries as $entry) { echo "<a href='{$entry->url}'>"; echo $entry->categories->title; //not working echo "<h2>{$entry->title}</h2>"; echo $entry->body; echo "</a>"; }; ?> Also how do I show on Jobs page (template: category) list of all posts that have jobs category selected?
      Thanks.

    • By Djemmers
       

      Hi,
      I am looking for a new cms to devellop the new version of my site.
      I have used joomla and modx but it was not really for me.
      maybe processwire is more for me?
      Can I do the following with this CMS?
      Use data in an external database (same server or other then site) to populate data on pages. (lists and detail pages)
      Add, delete, adapt entries in that database (through forms on frontend of the site)
      use my php and sql “knowledge” to adapt/create the above. (create custom php forms and php pages)
      create a multinlangual site (easy to add a language/tanslate file to be able to add languages)
      (optional: give users the option to use facebook/google or site registration)
       
      This for an event database website where:
      there is a hierarchical category system
      users can create an account/change their password
      logged in users can add/update/delete and search events.
      visitors (also not logged in) can add,search events.
      normal users can only acces front end even when logged in
      admin users can acces front and back end
      tnx for any replies
    • By tewdin
      First, I want to thank everyone who has been developing this great CMS. I really love it and I can do so much more and even learn more about coding. Now I try to create something new and very important for me, but I have a small problem with it.
      I am trying to make a website where users only see their own stuff or blank / redirect if not logged in. The problem is that I want to use the same template for all users, so I can't put a certain page as parent for selectable pages because the parent should always be /clients/username/categories/ (different path for every user).
      Input field type is Select or PageAutocomplete. User can create new categories through it.
      I would also like to know if there is a way to prevent users to see only what they have under their own /clients/username without making new templates for all users. I only show what I want them to see through templates but if they know the admin url then they would see all the pages and they would have access to edit all the pages which are created with certain content type. They need only access to create new content under their own "main page". This user page is created when a new user is registered and linked with field (content of the field is user id).
      Select is very important because every category gives special view for user.
      user1
      -- Project 1
      ---- Year
      -------- Things that user creates from Page 1.
      -- Categories
      ---- Things I want to use as Select List for new pages
      -- Project 2