Welcome Guest, Not a member yet? Register   Sign In
Making data available in ALL views

I am attempting to make some data available in all view files. This information is displayed in the page masthead and sidebar menu. I know I could pull the data in each and every single controller, but that is tedious and really not efficient. I would like to pull it at some global point and have it available in the view. 
The key is I don't want to have to modify all the controllers to pass the data to the view (or remember to pass in the future). How can I set a variable that is available in a view in say the base controller?
What I have so far (in the base controller):

PHP Code:
class BaseController extends Controller

$helpers = ["form""auth""phone""text"];


 public function 
initController(RequestInterface $requestResponseInterface $responseLoggerInterface $logger)


$session = \Config\Services::session();

$this->siteInfo siteinfo();
Then in the view I have:
PHP Code:
<?= $siteInfo ?>

I have confirmed that $siteInfo has data before you get to the view, but in the view I get: "Undefined variable $siteInfo"
Feels like I am missing something simple here... help!

Messages In This Thread
Making data available in ALL views - by SoccerGuy3 - 06-14-2021, 03:50 PM

Theme © iAndrew 2016 - Forum software by © MyBB