SubFolders and Collections

I am trying to understand how I can setup sub folders and how to control that the parent folder can see items from subfolders. So for example, let’s take the Blog Skeleton example. Say I wanted to have:

-blog
subblog 1
item 1
item 2
item 3
subblog 2
item 4
item 5

when I view /blog it should show: item 1 - item 5
when I view /blog/subblog 1 it should show : item1-item3
when I view /blog/tag:birds it should show any item in subblog folder with tag=birds
when I view /blog/subblog 1/tag:birds it should show only subblog1 items with that tag=birds

How do I do this? It almost works with the default skeleton, but on the /blog page I see ‘subblog’ as an item. So how do I tell the difference from a ‘subfolder’ and a real ‘item’? Is this controlled by the TWIG or how I define the collection?

In the /blog/blog.md file:

title: Blogs
blog_url: blog
body_classes: header-image fullwidth

sitemap:
changefreq: monthly
priority: 1.03

content:
items: @self.children
order:
by: date
dir: desc
limit: 5
pagination: true

feed:
description: Sample Blog Description
limit: 10

pagination: true


# My Gravtastic Blog
## A tale of **awesomazing** adventures
---

Also - forgot to mention that when I view:

/blog

it does not show any items that are in the subblog folders

so I do I tell the collection to go to subfolders? Where is this type of stuff documented so I do not have to ask such basic questions.

Thanks

You really need to paste these types of things between triple backticks (click the question mark in the forum text input box for help). I really can’t make any sense of your example structure because there are no indents.

Sorry - I hate when that happens and Muut does not let you edit a post

basically trying to figure out how to include items in top level folder that are items from a subfolder:

Folder structure

blog
  >>subblog 1
    >>>>item 1
    >>>>item 2
    >>>>item 3
  >>subblog 2
    >>>>item 4
    >>>>item 5

when I view /blog it should show: item 1 – item 5 (that are items of a subfolder)
when I view /blog/subblog 1 it should show : item1-item3
when I view /blog/tag:birds it should show any item in subblog folder with tag=birds
when I view /blog/subblog 1/tag:birds it should show only subblog1 items with that

There is a new feature coming in the next release of Grav that will make this easier. https://github.com/getgrav/grav/issues/341

it’s possible now, but you would have to ensure that all pages were built with appropriate taxonomy.

For example all your subblog1 item 1-3 pages could have a taxonomy like:

taxonomy:
  category: [blog, sublog1]

and all your items in subblog2 pages, ie item 4-5 pages would have this:

taxonomy:
  category: [blog, sublog2]

Then your blog.md page header would setup the collection like this:

content:
   items:
      @taxonomy.category: blog

And your subblog1.md page would have it’s collection setup like this:

content:
   items:
      @taxonomy.category: sublog1

So from the top level you get every page with category blog and then when your on the subblog1 page you only see pages with the subblog1 category.

Pretty easy!

I almost figured that out myself, but it still does not get the ‘child items’:

in blog/blog.md

content:
    items: 
        @taxonomy.category: blog

and in subblog1/blog.md

content:
    items: @self.children

which works beuatifully on the subblog pages /blog/subblog1,

but does not show item1 from subblog1 - how does

@taxonomy.category: blog

know to go a few levels deep, it seems to just find items in the current level.

Screen Shot 2015-10-20 at 12

Notice:
http://lp20poc-seatme.rhcloud.com/blog

does not show “SubBlog Item” that exeists in

http://lp20poc-seatme.rhcloud.com/blog/subBlog

When the pages are processed, it creates a taxonomy mapping for every page and their taxonomies. So it will find pages based on taxonomy no matter where they are in your site.

What does the page header of your /blog/subblog1/item1/item.md file contain (or whatever it is called).

BTW you get 3 minutes to make changes with muut forum :slight_smile:

yeha that would have been helpful:

/blog/subblog1/item1/item.md

title: SubBlog Item
date: 13:34 06/21/2014 
taxonomy:
    category: blog
    tag: [ocean, birds, photography]
    product: RhoMobile
---

So probably a caching thing - seems to be working now after I changed settings in system.yaml to turn off cache and page expifre to be 60 seconds

Thanks for speedy replies. Awesome

No problem. FWIW I usually run with cache off in development to be safe. it’s a bit slower, but better than wasting time on a caching issue.

And slower is relative when Grav is so fast anyway :slight_smile:

on a somewhat related question - can you have multiple types of collections on a page

like

content:
    items: 
        @taxonomy.category: blog
    items2:
        @taxonomy.category: subblog

on my main /blog page, I want to:

  1. Display blogs in main list area
  2. Display list of subblog in sidebar

You are in luck again! This is coming in the next Grav update: