2017 © Pedro Peláez
 

component f3-modules

Modules component for the F3-framework

image

dioscouri/f3-modules

Modules component for the F3-framework

  • Tuesday, September 1, 2015
  • by rdiaztushman
  • Repository
  • 6 Watchers
  • 4 Stars
  • 1,153 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 8 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

f3-modules

A module manager for the F3 framework, (*1)

Getting Started

Add this to your project's composer.json file:

{
    "require": {
        "dioscouri/f3-modules": "dev-master"
    }
}

Then add the following two lines to your index.php file, immediately before $app->run();, (*2)

// bootstap each mini-app
\Dsc\Apps::instance()->bootstrap();

// trigger the preflight event
\Dsc\System::instance()->preflight(); 

Adding Module Positions to the System

Yor front-end template probably has several custom module positions (header, footer, left, right, etc). Tell the f3-admin about them with the following code, which you should put in your apps/site/bootstrap.php, (*3)

// register the template'e module positions
\Modules\Factory::registerPositions( array('promo', 'footer', 'above-content', 'below-content') );

Displaying a Module Position in your template

Add the following to your template file to render modules in the "footer" position., (*4)

<tmpl type="modules" name="footer" />

Displaying a Module Position in a view file

Use the following code to render a module position within one of your views., (*5)

echo \Modules\Factory::render( 'your_custom_position_name', \Base::instance()->get('PARAMS.0') );

Add your project's modules to the system

To add your own custom modules to the system, put them all within subfolders of your own \Modules folder, for example:, (*6)

/apps/site/modules/

resulting in:, (*7)

/apps/site/modules/custom_module_1/
/apps/site/modules/custom_module_2/

Then register your module folder with the system:, (*8)

// register the modules path
\Modules\Factory::registerPath( $f3->get('PATH_ROOT') . "apps/site/modules/" );

Module filesystem structure

  1. Each module must have a module.json file in its document root, the contents of which is a single json object with at least a title (unique), eg:
{
    "title": "Your Custom Module"
}
  1. Each module must have a Module.php file in its document root that contains a single class. The class should be namespaced (e.g. \Your\Custom\Namespace) and the class name should be 'Module'. Finally, the class must extend \Modules\Abstracts\Module

Bootstrap your modules

All of your modules can have their own bootstrap.php file, and therefore can have their own Listeners. Put the bootstrap.php file in the root of their folder, such as:, (*9)

/apps/site/modules/custom_module_1/bootstrap.php
/apps/site/modules/custom_module_2/bootstrap.php

Add custom fields to the f3-admin module-editing form

Your module's Listener can add custom html to the f3-admin module-editing form. See the core Megamenu Module for a working example:, (*10)

f3-modules/src/Modules/Modules/Megamenu/Listeners/Admin.php

The Versions

01/09 2015

dev-master

9999999-dev https://github.com/dioscouri/f3-modules

Modules component for the F3-framework

  Sources   Download

GPL

The Requires

 

f3 rad module manager

01/09 2015

v0.9.0

0.9.0.0 https://github.com/dioscouri/f3-modules

Modules component for the F3-framework

  Sources   Download

GPL

The Requires

 

f3 rad module manager

29/08 2015

v0.8.1

0.8.1.0 https://github.com/dioscouri/f3-modules

Modules component for the F3-framework

  Sources   Download

GPL

The Requires

 

f3 rad module manager

29/06 2015