Welcome Guest, Not a member yet? Register   Sign In
Bays - Easy "widgets" for your views

(05-27-2015, 10:12 PM)kilishan Wrote: Introducing myth:Bays: a simple way to easily create and cache reusable "view fragments" for your views.

This is a solution to the HMVC dilemma - how to I easily insert view fragments from my libraries and modules without using "bad" HMVC controller-calling-controller practices. This allows you to get content from any class that can be autoloaded (or any CodeIgniter library). That content can be optionally cached so that the library is never loaded and no processing takes place for even more speed.

Need an example usage? Ok - say you've got a Shopping Cart module that you've written. You want the cart info/button to show up an all of the store pages, but you don't want to have to build a method into a MY_Controller to load it for every page, and you definitely don't want to hassle with loading that view in every controller method that it should be displayed on. Instead, you slide over to your template view where it should show up, and add the following single line of code:

$bay->display('cart::show_info_button', 'user='. $user_id .' state=open');

Now, this bay will locate and load up the Cart library, call the show_info_button method, passing an array of key value pairs to it that contains 'user' and 'state'.

This does assume that you've made $bay available within your views. Probably handled in your MY_Controller.

Since this is framework-agnostic, you can use it any project, but you'll have to create a couple of simple framework integrations. It does come with CodeIgniter integrations already, of course.

Would love to hear if you find this useful, and any thoughts on the project as a whole and even ideas for the future of it.

How do I install this? Tried composer install and nothing happened.


Messages In This Thread
RE: Bays - Easy "widgets" for your views - by frocco - 06-01-2015, 05:53 AM

Theme © iAndrew 2016 - Forum software by © MyBB