getgrav / getgrav/grav-learn

Custom content types do not work

Open
#696 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
248
Forks
752
Avg merge
1d 6h
Merged PRs (30d)
8

Description

Environment

grav 1.5.10 edit: same on 1.6.8
php 7.2

Description

The tutorial states that a custom defined media in media.yaml can be rendered with a custom twig file like *.ical.twig.

It does not work for 'ical' so I tested a true custom content type:

  abc:
    type: file
    thumb: media/thumb.png
    mime: text/abc

The according twig template is *.abc.twig.

Observation

After creating twig template and cleaning cache it does not work as expected.
The page trows a '404 page not found' error at system/src/Grav/Common/Processors/PagesProcessor.php.

The exact same twig file renamed to *.json.twig works, but with wrong mime header.

example.html -> work
example.abc -> do not work
example.json -> work

Questions

Maybe a additional file has to be changed? Hard coded '.html' and '.json'?

Reference

https://learn.getgrav.org/16/content/content-types

Maybe relevant #1818

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the content-types tutorial and its media.yaml example, then inspect system/src/Grav/Common/Processors/PagesProcessor.php, which the report identifies as producing the 404. Reproduce the reported behavior for the ical or abc template after clearing cache and compare it with the working json case. Done means the documented custom content-type behavior is verified and the needed documentation or issue reference is clearly identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.