maybe you are causing a loop yourself. fix it yourself.
There is something wrong with the javascript in the panel I think,
trying out some hooks and on page update, it just loads forever (extremly slow, localhost), but the
text file field is updated instantly… Just try it for yourself…
kirby()->hook('panel.page.update', function($page) {
try {
$page->update(array(
'hello' => "Please update me sir !!"
));
} catch(Exception $e) {
echo $e->getMessage();
}
});
your plugin is called nested because some other plugin with hook is calling $page->update() etc. they should fix it. but you can too.
a) just add a static lock to your plugin class.
haha. it always helps writing to the forum. explaining a problem is half way of solving it.
i just added a static ‘lock’ to my own class blocking the main function to be called nested.
private static $lock;
public function main() {
if(MyClass::$lock) return;
MyClass::$lock = true;
try {
// do work
} catch(Exception $ex) {
// maybe echo ex
}
finally {
MyClass::$lock = false;
}
}
b) or go all static with your plugin functions like revision plugin does.
Hello !
I’m in the same trap, I understand the idea of a lock, but I can’t manage to apply your fix to my case…
This is the code I try to make working without looping…
kirby()->hook('panel.page.update', function($page) {
if(isset($page->content()->data['compagnie'])) {
$compagnie = $page->compagnie()->lower()->toString();
try {
$page->update(array('compagnie' => $compagnie));
} catch(Exception $e) {
echo $e->getMessage();
}
}
});
And my attempt to convert it into an object with a lock was so dirty that I throw it…
In case its not too long for you to make an exemple of your fix with this code, you will make me reeeeeally happy !
@pierre : What I’m asking myself is why you need the hook at all for what you are doing there?
I would like to convert all tags to lowercase, to avoid duplicate tags. Is there an easier way ? I would rather to save them in lowercase than to convert them to lowercase in the filter.
Yes, there is a lower
option to automatically convert tags to lowercase.
2 Likes
pierre
June 9, 2016, 11:02am
6
Mea culpa… Kirby is too well made for me