Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Setting up a wiki index?

Started by Warren G Brown 8 years ago · 4 replies · 1508 views
8 years ago

Hello all,

I have a Grav site that is using theme learn2, It is a wiki site set up with hierarchical pages with each topic covering a subject and sub-pages covering parts of that topic. What I am wondering is if there is a way to use a twig to pull the title and link of all child pages (or descendent) and create a index link of all found entries. ie if the subject is linux and the child pages are php, mysql and apache. Then I can set the output of the linux page to be a listing of just links to these child pages pages (and if possible using descendents a nested listing.)

Any information is greatly appreciated.

8 years ago

First point I would make is that if you really want to create a wiki, you're probably better off using software designed for that purpose. I'm a fan of the flat-file wiki Dokuwiki.

You appear to be looking for what Grav calls Page Collections.

8 years ago

Thank you for the suggestion. I actually moved away from dokuwiki and I will say it was quite easy to process which speaks well for this cms. The reason I moved is that this cms does allow for a more stream lined access and setup hierarchically and moving data around at whim is much easier too. and the learn2 theme is much cleaner. I did find that I can get a listing of pages with links with the following:

frontmatter:

YAML
content:
    items: '@self.children'

Text area :

TWIG
{% for p in page.collection %}
[{{p.title}}]({{p.url}})<br />
{% endfor %}

Though this only give me one level down of data.

My goal overall is to learn how to use twigs in a way that lets me get children and then if possible children of children in a manner that lets me format the data with bullet points and sub level bullet points.

Does the content system allow for 2 variables that way a nested loop for be created?

I will continue to play around with the data and see what I can get.

8 years ago

You could use a plugin, too. DirectoryListing immediately comes to mind. Even if it doesn't quite meet your needs, if you're comfortable with PHP, you may be able to use it as a starting point.

8 years ago

Hi all,
I know this solution is far from being a Silver bullet, but here is what I did for the similar situation.

Toc plugin for individual pages + new Global Table of contents page for editors to append after creating an article.

  • But this only works for a closed group

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 57 14 hours ago
Support · by Anna, 3 days ago
2 65 17 hours ago
Support · by Justin Young, 18 hours ago
1 33 18 hours ago
Support · by Duc , 1 week ago
2 68 5 days ago
Support · by Colin Hume, 1 week ago
2 60 6 days ago