Models, I do something wrong, that don't works?

Hi,

I am trying to work with models :

My model collection.php
In folder models

In the template collection.php

Functions used in collection.php template don’t work

$image = $page->cover();

echo $page->hello("Arthur");

Do you get any error messages in your php error logs.

The above code should actually work.

What is your Kirby version?

BTW. Could you pls. post code as code blocks instead of screenshots? It makes it easier to test and correct code without having to write everything manually. Thank you.

I was on 2.2.2 i have juste change for test on version off kirby: 2.2.3.

Noting on php logs

Collection Model code :

<?php
/**
 *
 */

class CollectionPage extends Page
{

  public function cover()
  {
    return $this->image('cover.gif');
  }

  public function hello($name="Robert")
  {
    $text = "Bonjour ".$name;
    return $text
  }
}

There is a semicolon missing on the hello-functions’ return, line 17.

New code, nothing change

<?php
/**
 *
 */

class CollectionPage extends Page
{

  public function cover()
  {
    return $this->image('cover.gif');
  }

  public function hello($name="Robert")
  {
    $text = "Bonjour ".$name;
    return $text;
  }

}

That error should have been in the logs, have you turned on debugging in your config.php?

c::set('debug', true);

I tested your code in a fresh install and works for me.

What did you get in your page? With the missing semicolon, you should actually have ended up with a blank page. So I wonder if your template is actually used …

c::set('debug', true);
Is already set.

I think I find, one of my custom plugins doing wrong staff ! I keep looking.

Thanks for your help.

Totally missed that… so either the controller isn’t loaded at all because of some weird plugin, or the template isn’t used.

Have you checked if the content file is called collection.txt (or collection.en.txt on multilang site)?

edit: should have replied to @idris, of course :wink:

The template is correctly used.
Thanks for your help, it was definitely an error on my plugin.