FacebookTwitterFlickrYoutuberss

Version 7

From Zentyal Linux Small Business Server
Jump to: navigation, search

Index || < Prev | Next >


Version 0.7: composites

So far we have three different models with three different menu entries that help us to show their default views. It would be nice to be able to tell the framework to render the some modules together, using a given layout. That's where Composites come in handy. Composites help us to group our model views.

Composite view

The composite files are stored in src/EBox/Apache2/Composite. We should add our models to components and set printableName to Apache2 configuration. To do this, create the GeneralSettings.pm composite file with the following content:

package EBox::Apache2::Composite::GeneralSettings;

use base 'EBox::Model::Composite';

use strict;
use warnings;

use EBox::Gettext;

# Group: Protected methods

# Method: _description
#
# Overrides:
#
#     <EBox::Model::Composite::_description>
#
sub _description
{
    my $description = {
         layout          => 'top-bottom',
         name            => 'GeneralSettings',
         printableName   => __('Apache2 Configuration'),
         compositeDomain => 'Apache2',
         help            => __('Here you can manage your webserver settings'),
    };

    return $description;
}

1;


And register it in the YAML file schemas/apache2.yaml (adding the composites section):

class: 'EBox::Apache2'

models:
    - Settings
    - Modules
    - VirtualHosts

composites:
    GeneralSettings: [Settings, Modules, VirtualHosts]


Now, you should update the menu to point to the new location, edit src/EBox/Apache2.pm:

# Method: menu
#
#       Overrides EBox::Module method.
#
sub menu
{
    my ($self, $root) = @_;

    my $item = new EBox::Menu::Item(
        'name' => 'Apache2',
        'text' => __('Apache2')
    );

    $root->add($item);
}

Build and install the package. Go to the URL https://<your_ip>/Apache2/Composite/GeneralSettings and you will see something like:

Image(composite-1.png)

If you just change the layout from top-bottom to tabbed you will get:

Image(composite-2.png)


Index || < Prev | Next >

Template:TracNotice

Personal tools
Namespaces

Variants
Actions

Zentyal Wiki

Zentyal Doc
Navigation
Toolbox