Jump to content

Custom classes page make Exception error in loop


Recommended Posts


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 ?



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)?>">
            <?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>
<?php endforeach; ?>

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...