How to share function across all views
I'm just getting into using Mini3 MVC framework but am struggling with the concept of where to code a function that is to be used by ALL views. Can anyone help me? Thanks in advance
That's probably a question for yourself and how you want to structure your code.
You probably could create a function under the view folder - for example globals, and create functions there, like:
<?php
// file: application/view/globals/do_something.php
namespace Mini\view\globals;
do_something() { ... }
And in your view-files you could use your function like this: Mini\view\globals\do_something();
But you could put the function basically anywhere in the application folder.
There is not really a 'right' or 'wrong' predefined by Mini3 here.
That's probably a question for yourself and how you want to structure your code.
You probably could create a function under the
viewfolder - for exampleglobals, and create functions there, like:<?php // file: application/view/globals/do_something.php namespace Mini\view\globals; do_something() { ... }And in your view-files you could use your function like this:
Mini\view\globals\do_something();But you could put the function basically anywhere in the
applicationfolder.There is not really a 'right' or 'wrong' predefined by Mini3 here.
I will do that. Thank you for your guidance
@hollow6 @panique can we close this one?
@hollow6 @panique can we close this one?
Yes thanks