Migu Posted September 22, 2022 Share Posted September 22, 2022 Hello, I have Exception error in custom classes pages by foreach loop $child->overviewImages(4) but not when i call $page->getTest() it working Why ? Can someone help me ? Thank Regards User Error Exception: Method Page::overviewImages does not exist or is not callable in this context (in C:\dev\source\valtruffes\wire\core\Wire.php line 564) namespace ProcessWire; use RockMigrations\MagicPage; class OverviewPage extends Page { use MagicPage; public function init() { bd('init overview page'); } public function getTest() { echo "TEST"; } public function overviewImages($grid) { if ($grid == 12) { $image = $this->images->shuffle()->first()->size(1280, 400); } elseif ($grid == 6) { $image = $this->images->shuffle()->first()->size(640, 300); } else { $image = $this->images->shuffle()->first()->size(320, 200); } return $image->url; } } <?php $page->getTest() ?> <?php foreach($page->children() as $child):?> <div class="col-sm-4 wow fadeIn" data-wow-delay="0.2s"> <div class="icon-box-1 match-height mb30"> <?php if($child->images->eq(0) != null):?> <div class="box-images-<?=$child->id?>"> <img class="img-responsive" src="<?=$child->overviewImages(4)?>"> </div> <?php endif; ?> <div class="content-area"> <h3 class="title"><?=$child->title?></h3> <?php if($child->content != ''): ?> <div class="content"><?=substr($child->content, 0, 100)?>'...' <?php endif; ?> <p class="mt30"> <a href="<?=$child->url?>" class="btn btn-primary btn-theme page-scroll"><?=__('Plus d\'info')?></a> </p> </div> </div> </div> </div> <?php endforeach; ?> Link to comment Share on other sites More sharing options...
zoeck Posted September 22, 2022 Share Posted September 22, 2022 Do the child pages also have the custom page class? So in your example the template "overview"? Because the child pages are pages of their own. 1 Link to comment Share on other sites More sharing options...
Migu Posted September 22, 2022 Author Share Posted September 22, 2022 16 minutes ago, jmclosas said: That's it ! I testet now !! Thank you very much ! Link to comment Share on other sites More sharing options...
Migu Posted September 22, 2022 Author Share Posted September 22, 2022 16 minutes ago, zoeck said: Do the child pages also have the custom page class? So in your example the template "overview"? Because the child pages are pages of their own. The child pages did not have a custom page class but now I have created one and it works. Thanks a lot for your help Regards from Switzerland Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now