the goal is transforming something like this:
id1: "Audiogear -> Microphones -> USB-Microphones"
id2: "Audiogear -> Wireless equipment -> In Ear-monitoring -> Receivers"
id3: "Audiogear -> Wireless equipment -> In Ear-monitoring -> Senders"
id4: "Guitars -> Instruments -> Electric Guitars"
etc. for 485 records times 4 languages
to:
id1: "Audiogear", parent: root
id2: "Microphones", parent: 1
id3: "USB-Microphones", parent: 2
id4: "Wireless equipment", parent: 1
id5: "In Ear-monitoring", parent: 4
id6: "Receivers", parent: 5
id7: "Senders", parent: 5
id8: "Guitars", parent: root
id9: "Instruments", parent: 8
id10: "Electric Guitars", parent: 9
By dividing the category string into 4 sets of calculated fields (one for name, one for id) we get the different names and ids for each level.
For the first record:
level1id: 1
level1name: "Audiogear"
level2id: 2
level2name: "Microphones"
level3id: 3
level3name: "USB-Microphones"
level4id: null
level4name: null
Then for each following post we need to check if each level name has changed from the previous post using getnthrecord. If so assign a new id, else use the previous records levelid and levelname.
So far fine enough. But when we want to add an (reversed) ordering parameter to the result, like:
id1: "Audiogear", parent: root, order: 2
...
id8: "Guitars", parent: root, order: 1
We need to find out how many unique items there are for each level - from the bottom and up. Using getnthrecord on level2, 3 and 4 works fine as they change a lot. But level1 started showing "?" half way through.
Anyway - using valuelists all is good and performance is top notch!
For the fun of it I have included the file for reference ;)
categories.fp7.zip