Server Platform
Application Server
Content Generation
Class Library API
   Runtime System
Manual Index

next | previous

Content Database Templates Class

Templates are used to specify the general layout of documents or document parts. Elements could easily be embedded in those templates, representing dynamic or complex content.

Template Types

Template Types are used, to define classes of documents working on a similar set of elements and application functions, but having a different design and layout. Currently the following types are predefined:


Accessing Template Elements

Templates may be accessed via the following member function calls. They takes parameters of the form 'parameter name' => 'parameter value'

Template Name
Returns the name of the $i's element
my $Name = $Page->TemplateName ('Number' => $i);
Template Attribute
Returns the attribute of the $i's element
my $Attribute = $PageTemplate->TemplateAttribute ('Number'=> $i);
Template Content
Returns the content of the $i's element
my $Text = $Page->TemplateContent ('type' => 'parsed', 'Number'=> $i);

For example, you can put the following code in a template. If the 'Number' paramter is omited, all elements of this name are displayed.


  $Maxscape::Page::printElements ($self)


Element Generation Mainloops

The document generation actually takes place in a 'page generation mainloop'. When implementing a sites surface, the 'page generation mainloops' of the related templates must be designed to meet the special requirement.
At this point you may have a look at the file /maxscape/lib/perl/maXscape/SiteApplication/, which is included in this distribution The mainloops are called within the template pages to generate the text out of the page elements using the server API,e.g.:

sub standardTemplateLoop {
  my ($self) = @_;
  my $i = 0;

  $::Debug && &::Log ('Page.standardTemplateLoop', "Call standardTemplateLoop");

  if ($self->{Menu})
  $self->{ElementPrintAction} =  {map { $_ =>  1 } @{$self->{ElementsToPrint}}};

  my $Text = $self->TemplateContent('Name' => 'main',
                                    'Type' => 'parsed');
  unless ($Text) {
    $Text .= "At least you must define the template element 'main' "
          .  "containing some text for your "
          .  "template (" .  $self->TemplateName . ')'
          .  " of type (" . $self->TemplateType . ')'
          .  " with number (" .  $self->TemplateMainNumber() . ')'
          .  " containing some content.";
  if ($self->ErrorState()) {
    $Text .= "$self->{ClassName}\->standardTemplateLoop-err:" . $self->resetError();
  return $Text;

nextprevioustopbecome a membercontact © Maxscape