Concrete5 5.7: Passing variable from Controller to View -
so have made dashboard single page under:
/application/single_pages/dashboard/newsletter.php
and a
/application/single_pages/dashboard/view.php
the controller under:
/concrete/controllers/single_pages/dashboard/newsletter.php
the controller looks like:
<?php namespace concrete\controller\singlepage\dashboard; use concrete\core\multilingual\page\pagelist; use \concrete\core\page\controller\dashboardpagecontroller; class newsletter extends dashboardpagecontroller { public function view() { $testvar = array( 'one' => 'some', 'two' => 'value', 'three' => 'foo', 'four' => 'bar' ); $this->set('test', $testvar); } }
the /application/single_pages/dashboard/newsletter.php
looks like:
<?php defined('c5_execute') or die("access denied."); echo 'something'; print_r($test);
the /application/single_pages/dashboard/view.php
looks like:
<?php defined('c5_execute') or die("access denied.");
the problem:
the local variable $test
doesn't show in view.
the echo 'something';
showing, page , running. doing wrong?
it path & namespace issue:
the path controller must be:
/application/controllers/single_page/dashboard/newsletter.php
instead of:
/concrete/controllers/single_pages/dashboard/newsletter.php
for controller path singular single_page
single page plural single_pages
when extending core, need adapt namespace to:
application\controller\singlepage\dashboard
instead of:
concrete\controller\singlepage\dashboard
Comments
Post a Comment