NAME

OpenInteract::UI::Main - The primary user interface assembly 'conductor'

SYNOPSIS

my $page = OpenInteract::UI::Main->handler();
send_http_headers();
print $page;

DESCRIPTION

This is the handler that puts the main content generated together with the template that surrounds the content on every page.

The action has already been parsed from the URL for us so we look up the class/method used to generate the content and call them. We then put that content into the main template which is specified in our theme, unless we have received another directive to use a separate template or no template at all.

Another alternative is that the content handler needs to return a file that is not HTML, such as a PDF, graphic, word processing document, archive, or whatever. If so the content handler should put the complete filename in the $R->{page}->{send_file} key.

A content author can set a main template to use for the generated content by setting:

$R->{page}{_template_name_}

to the name of the template to use. This should be a fully-qualified template name -- such as 'mypkg::mytemplate'. If you do not specify a package the OI template provider will try to find the template in the global template directory.

You can also set a template that might vary by theme. This is not the name of the template directly but rather a placeholder within the theme which holds the name of the template. For instance, say you created a 'spooky_template' and implemented it in multiple themes. Even though you as an author do not know what theme will be used, you can still pick the right template by setting:

$R->{page}{_template_key_}

And to use the 'simple' template, the author should set:

$R->{page}{_simple_}

to a true value. The default 'simple' template is 'base_simple', although you can set its name under the template_names key of your server configuration.

Finally, the author can also set:

$R->{page}{_no_template_}

to display the content without a template at all.

Main Template Variables

Any content handler can send information to be placed directly onto the main template by setting information using the $R->{main_template_vars} hashref. For instance:

$R->{main_template_vars}{current_weather} = 'Rainy and cold';

would set the 'current_weather' template variable for display on the main template and not on any of the content handlers.

Note that while this sounds useful (and it can be), you will probably use it only very rarely. The 'boxes' concept is more comprehensive and full-featured and will almost certainly do what you need.

METHODS

handler()

Single method that performs the actions described above. Returns either a single scalar with the full page generated or undef, in which case the information to be sent is likely a non-HTML page that needs to be sent on its own.

DIRECTIVES

A directive (or 'page directive') is placed before the relevant action in the URL and tells OpenInteract to display the content in a certain manner. The directive should have been parsed out in the main content handler (OpenInteract.pm).

For instance:

/Popup/User/show/?user_id=716

Says that OI should use the template corresponding to 'Popup' to display the action 'User'. The correspondence is currently done in this handler but this will change shortly.

The directives used are listed in the server.perl file for a website, under the page_directives key.

TO DO

Nothing known, beyond write different ones of these (SOAP, etc.)

BUGS

None known.

COPYRIGHT

Copyright (c) 2001-2002 intes.net, inc.. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHORS

Chris Winters <chris@cwinters.com>