NAME

Para::Frame::Template::Components - Common template macro widgets

DESCRIPTION

These macros are defined in inc/html/c/components.tt and can be replaced by a custom implementation by a file with the same name in your TT path.

Widgets can be implemented either as exported objects (functions / methods / variables) or as templates for inclusion or defined template macros.

These are the standard widgets defined as TT macros. See also the standard Para::Frame::Widget module.

box

  box(part)

Draws a box where part is a Para::Frame::Result::Part object. It uses:

  part.title        = title in box
  part.message      = the message
  part.context      = More info
  part.context_line = The row number
  part.border       = The colour of the outer border
  part.width        = The width of the outer border
  part.bg           = The background colour of the box

The box uses the class paraframe_box

The message and context are written in <pre> blocks and are HTML escaped.

step

  step(label, template, run)
  step(label, template)
  step(label)

Draws buttons to navigate between forms.

searchstep

  searchstep(label)

Draws buttons for search forms.

actionstep

  actionstep(label)

Draws buttons for when the form has a given default action and template.

nostep

  nostep(label)

Draws buttons For not doing anything with this page, but continue to next step.

regret

  regret(label)

Draws buttons for going back to the previous page.

remove_step

  remove_step(label)

Draws a button for removing one step from the route.

backstep

Draws a button for going to the next step.

select

  select( $field, $current, @data, $valkey, $tagkey, $header )
  select( $field, $current, %data )

Draws a dropdown menu from a list of records (from a DB).

First version:

The select field has the name $field. @data is the list of records returned from select_list(). $valkey is the field name holding the values and $tagkey is the field holding the lables used in the dropdown. $current is the current value used for determining which item to select.

If $header is defiend, it's a label first in the list without a value.

Example:

  <p>[% select( "sender", "",
             select_list("from users"),
             "user_id", "username",
             "Choose" 
  ) %]

Second version:

%data is a hashref. The select will consist of all the keys and values, sorted on the keys. $current value will be selected. $field is the name of fhe field.

Example:

  <p>[% select("frequency", "",
  {
  	'1' = "every month",
  	'2' = "every week",
  	'3' = "every day",
  }) %]

hr

Creates a small hr.

sort

  sort(name, value, default_direction)

Draws a sort link to be used in a column header.

  name  = The label to draw as the column header
  value = the field name in the DB table to use
  default_direction = asc or desc

Default value is name

Default direction is asc

If the header is selected, it uses the class selected.

The sorting direction is placed in the variable direction.

The sorting field is placed in the variable order.

The offset is placed in offset.

Example:

  <h2>Translation</h2>

  [%# The default order here is sv and the default direction asc #%]
  [% order = q.param('order') || 'sv' %]
  [% direction = q.param('direction' || 'asc') %]

  <table>
  <tr><th>[% sort('English', 'en') %]</th>
      <th>[% sort('Swedish', 'sv') %]</th>
  </tr>
  [% FOREACH tr IN select_list("from tr order by $order $direction") %]
     [% tr2 %]
        <td>[% tr.sv %]</td>
        <td>[% tr.en %]</td>
     </tr>
  [% END %]
  </table>

expand

  [% WRAPPER expand label=$mylabel %]
     $content
  [% END %]

  [% WRAPPER expand label_show=$show_html label_hide=$hide_html %]
     $content
  [% END %]

Draws a widget with label_show or label. Click that label to expand the $content.

For collapsed state, the class paraframe_expand is used and for the expanded state, the class paraframe_expanded is used.

See Template::Manual::Directives/Processing Other Template Files and Blocks

imgexpand

  [% WRAPPER expand label=$mylabel %params %]
     $content
  [% END %]

Draws a widget with label and a img button. Click that label to expand the $content. Default label is an empty string.

class_expand is used for the label and button. Default is paraframe_imgexpand.

class_expanded is used for the $content. Default is paraframe_imgexpanded.

The content block gets id_block. Default uses a counter.

The label gets the id id_label. Default uses a counter.

The image beside the label uses label_expand_img. Default is $home/pf/images/button.expand.down.gif.

The params above can be given as params to the wrapper.

SEE ALSO

Para::Frame, Para::Frame::Widget

roundbox

  In .css:
    [% PROCESS css_components.tt %]
    [% roundbox($classname, $imgdir, $color, $background, $s_width) %]

  In .tt:
    [% WRAPPER roundbox imgdir=$imgdir title=$mytitle class=$classname %]
      Some contents...

      [% roundbox_subtitle($subtitle1) %]
      Some more...

      [% roundbox_subtitle($subtitle2) %]
      Some more...
    [% END %]

Draws a widget with rounded corners (or rather, with a frame of png's).

  $s_width is width (in px) of the side (A).
  $imgdir is concatenated with the following:

Header: h_bg.png - Background of header 1 × Ay px, Repeated in X h_left.png - Left of header (rounded corner) Ax × Ay px, Not repeated h_right.png - Right of header (rounded corner) Bx × Ay px, Not repeated h_left_wh.png - Forced min-size of left and top border Ax × Ay px, transparent h_right_w.png - Forced min-width of right border Bx × 1 px, transparent

Sides: s_left.png - Left side Ax × 1 px, Repeated in Y s_right.png - Right side Ax × 1 px, Repeated in Y

Subtitle: m_bg.png - Subtitle background 1 × Cy px, Repeated in X m_s_left.png - Left of subtitle A x Cy px, Not repeated m_s_right.png - Right of subtitle A × Cy px, Not repeated

Bottom: b_bg.png - Bottom border 1 × By px, Repeated in X b_left.png - Bottom left corner A × By px, Not repeated b_right.png - Bottom right corner A × By px, Not repeated b_height.png - Forced min-height of bottom border 1 × By px, transparent

calendar In (e.g.) header_extra.tt [% INCLUDE calendar_init.tt style="$css_path" %]

  In .tt
    [% calendar($name, $value, %params) %]

  Draws a calendar widget that returns the selected date to the input field specified.
  Uses input to draw the input field, forwards input's standard parameters and also "class" and "style".
  The field's id defaults to the fieldname.
  Use one of the supplied css-files in /html/pf/js/calendar (either as is or as a template for a new style).