Skip to content

All Components should have a plugin that shares name #28

@ChrisFrench

Description

@ChrisFrench

I was thinking we should have everything single component have a plugin that shares its name.

So For example I did this on ambra.
https://github.com/dioscouri/ambra/commit/20a46d105e790d4b9fbff93a7d88af9f94ba9b35

There is now a Ambra Plugin called ambra. and I added a new plugin event to the ambra.php file

Right now all it does is load the CSS and JS files.

function onInstanceSiteComponentAmbra() {
$app = JFactory::getApplication();
$doc = JFactory::getDocument();

       // Add related CSS to the <head>
    if ($doc->getType() == 'html')
    {

        jimport('joomla.filesystem.file');
        if( $this->params->get('enable_css', '1')) {
            if (JFile::exists(JPATH_SITE.'/templates/'.$app->getTemplate().'/css'.'/ambra.css')) {
                $doc->addStyleSheet(JURI::root(true).'/templates/'.$app->getTemplate().'/css/ambra.css');
            } else {
               $doc->addStyleSheet(JURI::root(true).'media/com_ambra/css/ambra.css'); 
            }
        }

        if( $this->params->get('enable_js', '1')) {
            if (JFile::exists(JPATH_SITE.'/templates/'.$app->getTemplate().'/js/ambra.js')) {
                $doc->addScript(JURI::root(true).'/templates/'.$app->getTemplate().'/js/ambra.js');
            } else {
                $doc->addScript(JURI::root(true).'media/com_ambra/js/ambra.js'); 
            }
        }    
    }

}

So now If you put a CSS in your template css folder called ambra.css it will use that instead of the code.

But this way if do this for all components and have all the plugin events listed there either blank methods or commented out it would make it really easy to customize the way the core works easier.

if we move some of our logic to our plugins you could basically .

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions