XAO::DO::Web::Header - Simple HTML header


XAO-Web documentation Contained in the XAO-Web distribution.

Index


Code Index:

NAME

Top

XAO::DO::Web::Header - Simple HTML header

SYNOPSIS

Top

Currently is only useful in XAO::Web site context.

DESCRIPTION

Top

Simple HTML header object. Accepts the following arguments, modifies them as appropriate and displays "/bits/page-header" template passing the rest of arguments unmodified.

title => 'Page title'

Passed as is.

description => 'Page description for search engines'

This is converted to <META NAME="Description" CONTENT="Page..">.

This is converted to <META NAME="Keywords" CONTENT="Page keywords..">.

path => '/bits/alternative-template-path'

Header template path, default is "/bits/page-header".

type => 'text/csv'

Allows you to set page type to something different then default "text/html". If you set type the template would not be displayed! If you still need it - call Header again without "type" argument.

Would pass the folowing arguments to the template:

META

Keywords and description combined.

TITLE

The value of 'title' argument above.

Example:

 <%Header title="Site Search" keywords="super, duper, hyper, commerce"%>

METHODS

Top

No publicly available methods except overriden display().

EXPORTS

Top

Nothing.

AUTHOR

Top

Copyright (c) 2005 Andrew Maltsev

Copyright (c) 2001-2004 Andrew Maltsev, XAO Inc.

<am@ejelta.com> -- http://ejelta.com/xao/

SEE ALSO

Top

Recommended reading: XAO::Web, XAO::DO::Web::Page.


XAO-Web documentation Contained in the XAO-Web distribution.

###############################################################################
package XAO::DO::Web::Header;
use strict;
use XAO::Utils;
use XAO::Objects;
use base XAO::Objects->load(objname => 'Web::Page');

use vars qw($VERSION);
$VERSION=(0+sprintf('%u.%03u',(q$Id: Header.pm,v 2.1 2005/01/14 01:39:57 am Exp $ =~ /\s(\d+)\.(\d+)\s/))) || die "Bad VERSION";

###############################################################################
# Displaying HTML header.
#
sub display ($;%) {
    my $self=shift;
    my $args=get_args(\@_);

    if($args->{type}) {
        $self->siteconfig->header_args(-type => $args->{type});
        return;
    }

    if($args->{'http.name'}) {
        $self->siteconfig->header_args(
            $args->{'http.name'}    => $args->{'http.value'} || ''
        );
        return;
    }

    my $meta="";
    $meta.=qq(<META NAME="Keywords" CONTENT="$args->{keywords}">\n) if $args->{keywords};
    $meta.=qq(<META NAME="Description" CONTENT="$args->{description}">\n) if $args->{description};

    $self->SUPER::display(merge_refs($args, {
                            path        => $args->{path} || "/bits/page-header",
                            TITLE       => $args->{title} || "XAO::Web -- No Title",
                            GIVEN_TITLE => $args->{title} || '',
                            META        => $meta,
                         }));
}

###############################################################################
1;