How does $kirby->set('option') work?

I added this in a plugin:

$kirby->set('option', 'plugin.revisions.limit', 10);

In the template I added this:

echo c::get('plugin.revisions.limit');

I expected it to print 10 but it prints nothing. Is it not indended to use it like this?

You can only set Kirby’s own options that way, not custom options I think.

The C class has a static array of key=>values, which you can add to with c::set and get from with c::get. When the $kirby object gets instantiated, it copies some of those values to its internal config. Which means that if you define a kirby setting in your config.php it will end up in the $kirby object, but if you do it in a template (and perhaps controller too) it will not.

For plugin options I would only use c::set and c::get.

2 Likes

Now that I think about it, isn’t there a $kirby->get('option', 'foo') registry method too?

1 Like

Yes, that works! Thanks! :smiley:

I start to not like the different syntaxes to do the same thing. I like shorter functions like u() instead of url() but many things just makes me confused.