Hi Everyone,
Ik have a problem with using the same Cell multiple times on the same page. The simplified version is:
To start with, I have a PagesController with a View action
public function view()
{ }
So I have a View file in the Template/Pages/ folder, named ‘view.ctp’. The content of this view file is:
<?php
$section = $this->cell('Test', [1]);
echo $section;
I have a standard Cell, named TestCell (in the View/Cell folder) with this content:
<?php
namespace App\View\Cell;
use Cake\View\Cell;
class TestCell extends Cell
{
protected $_validCellOptions = [];
public function initialize()
{
}
public function display($number)
{
$calc = $number+1;
$this->set(compact('calc'));
}
}
And a view file for the Cell, named ‘display.ctp’ (in the folder Template/Cell/Test) with this content:
<?php
echo $this->Number->currency($calc, 'EUR') ;
When I now visit the page project/Pages/View, The page loads as it should and I see:
€ 2,00
PERFECT! So far so good! But now my problem:
I would like to do the following in the view.ctp file (of course: simplified):
<?php
$section = $this->cell('Test', [1]);
echo $section;
$section_2 = $this->cell('Test', [5]);
echo $section_2;
I had expected that would work, but: It gives me the following error:
Fatal error : Cannot declare class Cake\View\Helper\NumberHelper, because the name is already in use in C:\xampp\htdocs\lpos\src\View\Helper\NumberHelper.php on line 30
I get that the NumberHelper is loaded twice somehow, and that the Cell seems to to this, but: I don’t know how to get around it or fix the issue.
I hope someone can help me out! Thanks in advance.