Welcome Guest, Not a member yet? Register   Sign In
CI 3 should has partial view or user control
#10

(02-10-2015, 06:40 PM)iamybj Wrote: plz note that , template is not enough.
Template is just a solution of sharing same part in view.
But some times, shared header\footer\sidebar have business logic too.
So the best method is nested a mvc into another mvc.

Common elements like that can always be pulled together in a MY_Controller that gathers the required info from different libraries and/or models.

Additionally, you can put together a small function that can do the "widget" thing for you. I implemented one a while back in response to someone else needing something like that and thinking you had to have HMVC, called Bays.

Or, if you're wanting full HMVC solutions, you can use WireDesignz' HMVC solution or one of the other HMVC solutions to get just what you're asking for.

Finally, if you namespace your classes, it's simple to add a static method to your modular classes to return the HMVC for that method. Then, in your views, just call that method, something like:

Code:
<?= \My\Namespaced\Library::show_sidebar_block() ?>

There's lots of possible ways to do what you're looking for. The one closest to what you've mentioned is the HMVC solution, and it's Modules::run() method, or using CI's packages and something like my Bays.
Reply


Messages In This Thread
RE: CI 3 should has partial view or user control - by kilishan - 04-04-2016, 12:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB