Jump to content

Storing nested data


Sipho
 Share

Recommended Posts

I am trying to create a sort of database system using ProcessWire. I don't want all the data to show up as pages on the website but instead pull it into pages. Similar to the Skyscrapers demo except in that one the data shows up as pages. The data I wish to store is information about types of moths. So family, sub-family, genus and species. Each of these has information associated with it. For example, species has name, images and distribution. This is another example of information about the species. Initially, I attempted to do this using nested repeaters. This appears to work but I feel there is a better and more elegant way. Additionally, this page says: 

Quote

Repeaters aren't infinitely scalable in quantity, so avoid repeaters for quantities of items that you think may need to be infinitely scalable. 

...

It's better to use pages without repeaters when dealing with huge quantities of items. 

So I then tried using pages with children, but this also didn't work well. I had to make every single page unpublished as I don't want them showing up in menus and other places. This means they all have strikethroughs in the admin tree which is very annoying.

Is there a better way of handling this kind of data in ProcessWire or is this maybe not a suitable project for ProcessWire? I apologise if this is a silly question, but I could not find anything on this matter and am still new to ProcessWire.

Link to comment
Share on other sites

Hi @Sipho,

Welcome to the forums.

Instead of unpublished you could also make them hidden. They won't show in a $pages->find() either unless you explicit ask: $pages->find('include=hidden')'.

Also check out this famous post on how to organise content in ProcessWire with great examples. This will give you good insight on possibilities on how to structure your data.

 

  • Like 2
Link to comment
Share on other sites

In addition to all the above.

On 2017-7-10 at 8:00 PM, arjen said:

Instead of unpublished you could also make them hidden. They won't show in a $pages->find() either unless you explicit ask: $pages->find('include=hidden')'.

 @Sipho If you want to make sure hidden pages never show up accidentally (say they have a template, guest access, and someone happens to know/figure out its URL) then you can turn hidden into password protected with @adrian's great PageProtector module easily:

Another tip when dealing with related data: you might want to take a look at @Robin S's cool module:

Hope this helps too.

  • Like 2
Link to comment
Share on other sites

So after looking at 

and looking at my data again I came up with the following structure:

Capture.PNG.54fbd659269ce1a75ddd3fe6442c804d.PNG

The structure is families -> family -> subfamily -> genus -> species

This is how I originally thought of doing it, but I thought it would cause problems when I wanted to add new species and filter data. However, I have now realised that having a good page structure is very desirable. This way, people can link to the individual categories or browse through them but I can still have a separate page that references them and can filter through them.

Thanks for the help!

Also, I am loving how easy it is to use ProcessWire! It's much better than something like WordPress for a task like this. I don't have to constantly fight the system :)

 

  • Like 2
Link to comment
Share on other sites

7 minutes ago, Sipho said:

I am loving how easy it is to use ProcessWire! It's much better than something like WordPress for a task like this.

This is because as the inventor says:

"ProcessWire IS a native category system, whether by structure or relation. I think the distinction is that we don't call them "categories" or "tags". But "does not have" makes it sound like they aren't part of the plan. When in fact, it's one of the underlying purposes of the system."

to read more:

 

  • Like 2
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

×
×
  • Create New...