-
Notifications
You must be signed in to change notification settings - Fork 2
5.2 Build your own outlet placeholder
Outlets you registered with the framework will need a place to be shown to the user. Usually this could be a general page that serves as a collection of many features represented by many different outlets.
Creating an outlet placeholder is very easy. Simply register an outlet name within a service provider's register method.
resolve('frameOutlet')->registerOutlet('MyOutletName');
Note: Outlet Names should be unique. It will be used as key to identify placeholders among others.
-
Render the outlets
You can render the outlets in blade files or anywhere you like. Each outlets registered with the placeholder has a method called "getView()". Use this to render your outlet in a blade file.
@foreach (app()->frameOutlet->getOutlet('MyOutletName') as $OutletItem) @php $view=$OutletItem->getView(); if ($__env->exists($view->Name(),$view->getData())){ echo $__env->make($view->Name(),$view->getData())->render(); } @endphp @endforeach
Note: To differentiate each section, you can use $OutletItem->MyName() to set titles or tab names for the section of the outlet contents.
-
Attach outlet resources
Should your outlet contents have any asset files to be inserted before rendering the contents. You could process them within any header files or push them into a blade stack. Use the following to fetch and insert all assets files.
foreach(app()->frameOutlet->OutletResources('MyOutletName') as $asset){ app()->FeFrame->enqueueResource($asset,'footerscript'); }
Note: app()->FeFrame->enqueueResource is a method used by the framework to uniquely register a library to a list. It takes 3 parameters.
- First parameter is the resource file
- Second parameter is the location name of the stack. All resources will be pushed to this named stack and you are free to place that @stack anywhere in any blade files. Default is the framework's headerstyles, and it's loaded just before the body tag.
- Third parameter is either to push the asset to the end or prepend it to the beginning of the list.
I know this could be overwhelming and perhaps my approach to accomplish such feature might even be less effective. But to look at a complete example of how to use a placeholder, output their contents, generate a stack tag, push assets to stacks and to render the stack, consider reviewing the following.
For registering assets with tags for every outlets
/vendor/feiron/felaraframe/src/resources/views/controlPanel.blade.php Line:23-25
For rendering outlets within tab structures
/vendor/feiron/felaraframe/src/resources/views/controlPanel.blade.php Line:32-52
"OutletResource" stack is placed under
/vendor/feiron/felaraframe/src/resources/views/index.blade.php Line:53
Feedback is much appreciated! I can be reached at [email protected]