.

The basic page modules described in the introduction are not themselves overridden in plugins, as there is a group of ancillary modules designed for this task:

Document::Configure
This module can be used to add or remove standard template elements, or replace them with customized elements from your plugin
Document::HTML::<module name>
These modules output the chunks of HTML that make up the template. By creating your own alternatives to these modules and then specifying their use in Document::Configure, you can alter many aspects of the template

Replacing a global element

Let's say that you want a different set of links in the blue bar that sits under the search box. First you need to create a copy of the appropriate file (EnsEMBL::Web::Document::HTML::HelpLink.pm) in the appropriate plugin namespace, and edit it to output the HTML you want:

package EnsEMBL::MyNamespace::Document::HTML::HelpLink;
use strict;
use CGI qw(escapeHTML escape);
use EnsEMBL::Web::Document::HTML;

use constant HELPVIEW_WIN_ATTRIBS => "width=700,height=550,resizable,scrollbars";

our @ISA = qw(EnsEMBL::Web::Document::HTML);

sub new           { return shift->SUPER::new(); }

sub render {
  my $self = shift;
    
  my $home = $ENV{'SITE_LOGO_HREF'}; ## Assuming your logo links back to your mirror's home page
  my $html = qq( <a href="$home">HOME</a>  &middot; <a href="/info/contact.html">CONTACT US</a> );

  $self->print( qq(
<div id="help"><strong>$html</strong></div>
));
}

1;

Next, you need to create a Document::Configure module in your plugin that replaces the original module with yours:

package EnsEMBL::MyNamespace::Document::Configure;

use EnsEMBL::Web::Root;
our @ISA  = qw(EnsEMBL::Web::Root);

sub common_page_elements {
  my( $self, $doc ) = @_;
  $doc->replace_body_element qw(helplink EnsEMBL::MyNamespace::Document::HTML::HelpLink);
}

1;

In the call to replace_body_element, the first parameter is the key that identifies the template element in the base webcode, and the second parameter is the name of your replacement element.

Adding a section to the static content menu

Let's say you would like all static pages to have an extra section of links to useful pages. Because the left-hand menus are handled dynamically, no Document::HTML::ExtraLinks module is needed. Instead we configure the list directly in Document::Configure:

package EnsEMBL::MyNamespace::Document::Configure;

use EnsEMBL::Web::Root;
our @ISA  = qw(EnsEMBL::Web::Root);

sub static_menu_items {
  my( $self, $doc ) = @_;
  $doc->menu->add_block( 'extra_links', 'bulleted', 'Useful Links', 'priority' => 100 );

  $doc->menu->add_entry( 'extra_links',
    'href'  => 'http://www.biocorp.com/',
    'text'  => 'BioCorp Intranet',
  );

  $doc->menu->add_entry( 'extra_links',
    'href'  => 'http://www.genome-institute.edu/projects/acme',
    'text'  => 'ACME Genomics Lab',
  );

}

1;

The priority parameter controls the order of blocks in the menu bar - by tweaking this value you should be able to get your block to appear anywhere in the left-hand column.


 

© 2024 Inserm. Hosted by genouest.org. This product includes software developed by Ensembl.

                
GermOnline based on Ensembl release 50 - Jul 2008
HELP