Include a parent_folder_position key in the story object

e.g say i have a products folder that has sub-folders for each category. Each category folder has a start-page for that category and multiple product pages inside as per layout below

   products folder >
       category folder >
           category page
           product page
           product page
           product page
       category folder >
           category page
           product page
           product page
           product page

let’s say i want to get all category stories for a “All products” page, you can fetch from cdn/stories?starts_with=products?is_startpage=1/ However, the order will not match the category folder structure as instead it will order off the current position which is based on the position of the category page within it’s own folder. so some of category stories will have the exact same position, 0, and they will not match the folder positions.

Options to get around this are as follows:

  • fetch links for the products folder, filter out the start-pages and then use the uuid’s to fetch each story by uuid_order.

  • make separate category and products main folders and link to one from the other. This means the category pages will order per position under the one folder. This itself can be a pain because the side effect will be all products within one folder can get out of control to filter through. Yes, you can make sub-folders inside to separate products into categories, however you can quickly run into issues with dynamic routing on the front-end. e.g a category page url would be ‘products/:category’ and a products page would ideally be ‘products/:category/:product’ so if you were to split the products into separate folders the slug would have to exactly match that of a category due to the :full-slug being used to get one story.

*multiple different field type implementations could make something work, yet can be hard to keep track of and may need to be used in different places which will be repetition e.g the navigation menu, and the all products page.

I don’t know if I’ve missed something , but i feel like this would be a useful implementation for ordering based on the position of items in the content folder.

Feel free to let me know if there is a better way around this?

Also, in the link object the position for folders is already there.

Hello Andrew,

this would work and additionally you do have the parent ID:

**"parent_id":0,** <--

In the case that the products folder has a sub-folder you could even use the parent ID to filter its items out or sort items in their own lists and bring items of several folders into the correct order.
1 Like

yeah, i think this is the way ill stick with for now. It allows for the implementation to be more dynamic.

Ill generate the tree as per your sitemap tutorial.

I still think it would be good to only have to grab multiple stories objects and arrange per “parent_position” instead of a two request process.

1 Like

I will write a feature request on Github using your use-case and post the link here when I finished it.

1 Like

I’ve added it as a feature request: :slight_smile:

Have a nice rest of the week!

With best regards