Add a customfield in the panel that changes depending on other fields

Umm, where do I see this?
I downloaded Kirby one week ago.

Found it. 2.0.6

Then you must be on 2.0.6 and the feature was added in 2.0.6 as well,

<?php
echo kirby()->version() ;
?>

Yep thats the version I got

Do you get an error message (with debug turned on) or just nothing at all ? I tested this on a Kirby 2.1 beta install without any problems

I turned debug on now

This error came:

Fatal error: Function name must be a string in /Users/sitch/GitHub/kirby/site/templates/review.php on line 40

This the line:

<?php $page('review')->scoreaverage() ?>

It should be page('review') instead of $page('review'), i.e. without the $-sign

Oops. Fixed it.
Now a new error:

Fatal error: Call to a member function scoreaverage() on boolean in /Users/sitch/GitHub/kirby/site/templates/review.php on line 40

Anyway, if you are calling the method on the review page, then $page->scoreaverage() is your friend. If you try to call it from another template, then use page(‘review’). But I don’t think that’s the problem here …

At the moment I try call it from the same template.
My template name is review.php and the function is in /models/review.php

I now used <?php $page->scoreaverage() ?>
and now theres no php error. But it just dont do anything.

Aaaah I am stupid! I forgot the echo!
Now its working!! Thank you <3

And if I need use it from another template then I use page(‘review’)?

exactly, page('review')->scoreaverage() from other pages

Had to bring this up again.

@lukasbestle said

You can create an actual field “finalscore” and decide from your model method whether to calculate the score or whether to return the fixed score depending on the value of the field (if it is empty or contains a value).

i tried the model approach, but see no way to actually post that value to a field. how would one do that?

You would do that from the Panel (or directly in the file system). Afterwards, your model can read the actual field value using parent::finalscore().