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; ?>