Template for subpage is not selectable

Hi,

I have a (minimal) blueprint for a blog page - basically only

title: Blog
preset: pages

however, on this page, when I click “add new” in the panel, only the template “Blog” is selected, and the select is disabled.
I have existing subpages in the content directory /content/blog/1_article-a/blogpost.txt
and a blueprint for the blogpost template:

title: Blog-Post
preset: page
fields:
    headline:
        label: Überschrift
        type: text
    summary:
        label: Zusammenfassung
        type: textarea
    body:
        label: Inhalt
        type: textarea
    date_start:
        label: Veröffentlicht ab
        type: date
        width: 1/3
    date_end:
        label: Veröffentlicht bis
        type: date
        width: 1/3
    url:
        label: Link
        type: url
        width: 1/3
    projects:
        label: Projekt-Bezug
        type: pages
        query:  site.find('projects').children.template('project')
        layout: cards
        image:
            ratio: 3/1

those pages work as expected, only I cannot add a new blogpost via the panel.

Strangely a similar setup for project/projects in the same install works fine:

Projects blueprint:

title: Projects Page
preset: page
pages: project
    limit: 50
files: false
fields:
    competences:
        label: Kompetenzen
        type: tags

Project blueprint:

title: Project Page
preset: page
pages: false
files:
    layout: cards
fields:
    client:
        label: Kunde
        type: text
    project:
        label: Projekt
        type: text
        width: 1/2
    url:
        label: Link
        type: url
        width: 1/2
    competences:
        label: Kompetenzen
        type: tags
        accept: options
        options: query
        query: site.find("projects").competences.split
    ended:
        label: Status
        type: toggle
        text: Beendet
        width: 1/3

    date_start:
        label: Projektbeginn
        type: date
        when:
            ended: true
        width: 1/3
    date_end:
        label: Projektende
        type: date
        when:
            ended: true
        width: 1/3

I have a controller for “blog”, but this should not influence the panel?

controllers/blog.php

	return function ($site,$page) {
		// set htmltitle
		$title = $page->title() . ' - ' . $site->title();

		// fetch items for hero-slider
		$heroSlides = [];
		$heroIntro  = page('projects')->find('intro');
		$heroSlides = page('home/projects')->active_projects()->toPages()->shuffle();
		$heroSlides->prepend($heroIntro);

		$articles          = $page->children()->listed();
		$articlesPublished = $articles->filter(function($child){
			$now   = time();
			$start = $child->date_start()->toDate();
			$end   = $child->date_end()->toDate();
			if (!empty($end) && $end < $now || !empty($start) && $start > $now) {
				return false;
			} else {
				return $child;
			}
		});
		$articlesSorted = $articlesPublished->sortBy(function ($child) {
  			return $child->date_start()->toDate();
		}, 'desc');

		return [
			'articles'   => $articlesSorted,
			'htmltitle'  => $title,
			'heroSlides' => $heroSlides
		];
	}

(yeah I know, there’s still room for improvement :wink:

But I’m at a loss regarding the template of the blog posts…

cheers,
Tom

Try adding the templates option to the blog blueprint:

title: Blog
preset: pages
templates: blogpost
1 Like

No changes to the template selection.

That’s so weird.

Could you try to add the sections manually?

title: Blog
sections: 
  drafts: 
    headline: Entwürfe
    type: pages
    template: blogpost
    status: draft
  published: 
    headline: Veröffentlicht
    type: pages
    template: blogpost
    status: published

strange. still no difference. Other changes, like changing the title or the labels, get applied immediatly.
Is “blog” something that’s used in the system? On the other hand, I already tried to rename the blueprint and text files, made no difference.

No, definitely not.

And the blog page is definitely using the blog blueprint? I.e. the text file inside the blog folder is called blog.txt?

And the blog page is definitely using the blog blueprint? I.e. the text file inside the blog folder is called blog.txt ?

Hi thanks for looking into this. yes, the blog.txt is in /content/2_blog/:

This is weird. Everything works as expected - if I create a new page via the panel (with the wrong template) and then rename that blog.txt to blogpost.txt, all is well in the panel.
If I create new folders and the txt manually in the filesystem, it works, too.
I even deleted my blog and blogpost controller, just to see if this makes a difference, which it doesn’t.
This is the latest Kirby Version btw, I only installed it last friday.

That is really weird. If I put those two files into a Starterkit, it works as expected. Have you tried to clear the browser cache, delete all sessions files etc.?

This gets stranger by the minute. If I delete the blog.txt, and put in a new default.txt, the this is the only template pre-selected for the subpages.

In the meantime I deleted all session data (logged me out), and cleared the browser cache/session, and started new. O_o

Yes, that’s because of this setting in default.yml (at least if you still have the one from the Starterkit)

pages:
  template: default

So it’s currently the one thing that is not weird :wink:

1 Like

Yes it is, since in my default.yml there’s no limitation for the templates (and in every other page with default template I can select the other templates). I’m at a total loss here. This happens only in the blog/ content, no matter how I rename the files.

Is your project publicly available on GitHub for testing?

I can sent you a zip… there’s no really sensitive info involved

1 Like

Fine, can you send me link via PM?

1 Like

(in the menatime I tested with a different browser to exclude some local JS problems or else… no difference)

you got mail errm DM :wink:

I really hope you find out what it was. Let me know if you need me.

1 Like

Ok. Of course this issue has nothing to do with Kirby.
There’s a left-over rewrite rule from the old website that handles requests to “blog” URLs.
This seemingly clashed with the ajax-request from the panel - and only to “blog” requests, hence the problem with my “blog” blueprint/template, and only on the first level of nesting.
d’oh. stupid tom, stupid. :slight_smile:
Thanks for the support, however <3

1 Like