Forums / Install & configuration / Layout/structure of extensions

Layout/structure of extensions

Author Message

Peter Rudolfsen

Wednesday 24 March 2010 3:25:43 am

I'm setting up an installation of ez that will contain a large number of sites and custom extensions.

My first thoughts about this, is that it would be nice to be able to use a tree-structure inside the extension directory to improve the overall usability and layout for this.

A tree-structure would also allow me to be more flexible in how each site/extension is hosted in a version control system, for example if using GIT each top "package" or "node" can be in it's own repository.

This is a first thought/blueprint of a layout:

 extension/

    ... ez core extensions ...

  common_custom_extensions/

    extension1

    extension2

  sites/

    example_site1/

      site_extension_with_design

      custom_site_extension

    example_site2/

       extensions ...

Even though nothing in the documentation or examples indicate that this is possible, it actually is, by specifying the relative path to each extension in 'ActiveExtensions', 'ActiveAccessExtensions' and 'DesignExtensions'.

Example:

[ExtensionSettings]
DesignExtensions[]=sites/example_site1/site_extension_with_design
ActiveAccessExtensions[]=sites/example_site1/custom_site_extension

So the big question is; are the ini settings meant to contain the path, or the name of the extension?

Cause if it's a coincidence that this works, and that the support for this may be broken in any future version, then I'd think again to structure it this way.

What are your thoughts?

Nicolas Pastorino

Wednesday 24 March 2010 3:49:02 am

Let's start some brainstorming all together :)

So you are saying that specifying the full relative path to an extension in site.ini actually works ?
Tried with many different extension types ?

Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Peter Rudolfsen

Wednesday 24 March 2010 4:05:50 am

There are probably some extensions out there that have 'ifs' or similar logic around the names of an extensions, but those can be easily overcome by exploding the string and getting the last element.

But of course, if there are loads of extensions with logic around extension-names, it might not be that easy to specify paths like this.

I still think this is a good idea, cause you could also add support for enabling extensions based on it's parent, or parents parent etc...

Peter Rudolfsen

Sunday 28 March 2010 11:46:53 pm

I have a few additions around this...

ExtensionAutoloadPath also needs to be modified to fit the new structure.

And the worst part is that all the $eZTemplateOperatorArray arrays need to be changed too. I was hoping to make this possible without having to change any code, but I can't see how that's possible at this time.

Peter Rudolfsen

Sunday 25 April 2010 1:50:17 am

I've managed to structure all extensions / sites in a tree, and still load them the traditional way by using this method:

http://share.ez.no/forums/setup-design/multiple-siteaccess-design-solution#comment58711

Abdelkader RHOUATI

Sunday 25 April 2010 6:37:09 am

class eZExtension
{

....


  static function activateExtensions( $extensionType = false ){
                $extensionDirectory = eZExtension::baseDirectory();            $activeExtensions = eZExtension::activeExtensions( $extensionType );              $hasExtensions = false;
        $ini = eZINI::instance();
        foreach ( $activeExtensions as $activeExtension )
        {
          $extensionSettingsPath = $extensionDirectory . '/' . $activeExtension . '/settings';
          if ( file_exists( $extensionSettingsPath ) )                 {
             $ini->prependOverrideDir( $extensionSettingsPath, true );
             if ( isset( $GLOBALS['eZCurrentAccess'] ) )
             { 
                eZExtension::prependSiteAccess( $activeExtension );
             }                              
             $hasExtensions = true;
         }
         else if ( !file_exists( $extensionDirectory . '/' . $activeExtension ) )
         {
                eZDebug::writeWarning( "Extension '$activeExtension' does not exist, looked for directory '" .  $extensionDirectory . '/' . $activeExtension . "'" );
         }
      }
      if ( $hasExtensions )
           $ini->loadCache();

     }

.......

}

Peter, The operation that you describe is quite logical, above the function ez, which checks if an extension enabled exist, with the line:
! File_exists ($ extensionDirectory. '/'. ActiveExtension $);

($extensonDirectory: the directory "extension" ;
$activeExtension: name / path in the settings files for each extension)

I think if you put the name of the extension,or the path of the extension, EZ doesn't care, the important thing is that the directory of the extension exists

.
It will be useful, sometimes you end up with more that 20 extensions, it will be good to group them into separate directories, somethings like that:

extension /
ezsystem /
.... (Default extension that comes with ez)
Design /
....
webservices /
....

TKS,

Regrads

Abdelkader RHOUATI

Blog (french) : http://arhouati.com
----
Extension arh_jdebug : EzDebug using jquery