Custom page type controller not loaded for anon users
Permalink
I have a custom page type controller which, it seems, is only called for admin users but not for anon users.
The relevant part in the page type template looks like so:
And my whole page type controller looks like so:
Anon users see an error message:
"
Warning: Invalid argument supplied for foreach() in ...themes/hr-d/shop_home.php on line 12
"
Admin users see the teaser images in a carousel.
Even stranger, I have been unable to reproduce this behavior on my dev system.
Using instead of does not change the result.
Dev system and live system differ in their PHP minor version: 5.4.6-1ubuntu1.1, resp. 5.4.11.
Also they differ in the way PHP is loaded: dev uses mod_php whereas live uses mod_fcgi.
Both systems use rather aggressive caching, "Full Page Caching" is set to "On - in all cases".
At this point I have no more ideas... What definitely is wrong with my code? What could be wrong? What else could I look into?
The relevant part in the page type template looks like so:
And my whole page type controller looks like so:
<?php class ShopHomePageTypeController extends Controller { protected $c = NULL; public function on_before_render() { $this->c = Page::getCurrentPage(); $this->set('teasers', $this->loadTeasers($this->c->getCollectionID())); } public function loadTeasers($collectionId) { $teasers = Cache::get('teaser', $collectionId); if (!empty($teasers)) { return $teasers;
Viewing 15 lines of 46 lines. View entire code block.
Anon users see an error message:
"
Warning: Invalid argument supplied for foreach() in ...themes/hr-d/shop_home.php on line 12
"
Admin users see the teaser images in a carousel.
Even stranger, I have been unable to reproduce this behavior on my dev system.
Using
view()
on_before_render()
Dev system and live system differ in their PHP minor version: 5.4.6-1ubuntu1.1, resp. 5.4.11.
Also they differ in the way PHP is loaded: dev uses mod_php whereas live uses mod_fcgi.
Both systems use rather aggressive caching, "Full Page Caching" is set to "On - in all cases".
At this point I have no more ideas... What definitely is wrong with my code? What could be wrong? What else could I look into?