Jump to content
Sipho

Storing nested data

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.

Share this post


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

Share this post


Link to post
Share on other sites

@ian has a site about moths, maybe he can help you. 

 

  • Like 1

Share this post


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

Share this post


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

Share this post


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

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 michelangelo
      Hello guys,
      very simple question about repeaters from the Core Modules. I have used them before without issues. This one concerns a weird behaviour which I am not sure whether it's caused by me not using it correctly or a bug. The problem is that when I add content, save it, refresh the page and return to the page, I cannot unfold the repeater. I made a video so you can see the behaviour (below)
      I tried re-initiating the repeater field, but still doesn't work...

      Looking forward to your advice!

      Thanks!


       
      repeater-problem.mp4
    • By benbyf
      Hello, and welcome to what I though was either my client being silly and changing things, or some evil doer. Turns out its reproducible and therefore something in Proceswire (I checked my templates and modules but couldnt find anything that would be doing this...). So what is it doing? Check out the video for evidence.
      A repeater field is interacting with a page template and another repeater field somehow to swap the fields in the template and repeater over...
      I have a template called team, and a repeater field called team_repeater with label Team. Some how and for some reason, when I change my fields on repeater called main_menu_links my team template gets those fields and when I try and revert the team template fields to the fields it should have, they get given to the repeater main_menu_links. Also this to say HELP!!!!!
      video: https://www.dropbox.com/s/exkdhc6n7x0xpsa/strange-repeater-PW-mega-bug.mov?dl=0
    • By neonwired
      I have a front end form for creating new pages, repeater and repeater matrix field don't seem to save any data. I was considering handling the data manually but can't seem to get anything useful from the post data, are there any methods i can use?
    • By benbyf
      Hi, Looking to create form elements on a page–some input with a colection of form inputs and the appropriate labels and variables for that input. I've used ProForms in the past and rolled out my own when creating simply one off forms, but I wonder if anyone has found a good way of allowing form creation on page editing so that clients can adhocly make and edit forms?
      Thanks
    • By t0b1
      Hello there, and thanks for ProcessWire!
      I'm getting to know ProcessWire while doing my first project using it and I really like it so far.
      The challenge I'm facing right now is the following:
      I have a One-Pager using fullpage.js, realized as a single PW-Page containing a Repeater Field where each Repeater Item is one Section.
      Some Sections are supposed to have a little menu at the Top which references/links to different Sections of the Website, so I wanted to use a Checkbox Field "Top Menu" to decide if a Section gets a Menu and a Page Reference Field to choose the different Sections (Repeater Items) it should contain.
      I've already accomplished this by pasting the following code into /site/ready.php:
       
      $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'top_menu_entries') { $page = $event->arguments('page'); if($page instanceof RepeaterPage) $page = $page->getForPage(); $event->return = $page->; } });  
      The only problem that still remains is that when I select the Entry of the Repeater Item itself it doesnt save the selection, meaning after I saved it's unselected again.
      On some Sections I do want a Menu-Entry for the Section itself though (which would be styled differently and not link anywhere) for Continuity-Reasons, any ideas on how to achieve that?
×
×
  • Create New...