Proposal:WidgetSetLoop

From MovableType

Contents

mt:WidgetSetLoop: A Proposal for controllable widgetset output

Abstract

The current implementation of widgets amounts to a convenience tag fronting a convenience interface, and provides no control over output. The WidgetSetLoop tag is proposed as an alternative for template creators needing more options.

Problems & Use Cases

The only way currently available to output a widgetset is via the WidgetSet tag, used similarly to:

<div id="my-widgetset">
<$mt:WidgetSet name="someset"$>
</div>
  1. If a widget set within some container(as above) is modified to have no widgets, markup is still output(an empty "my-widgetset" div). It should be possible to prevent this for basic markup cleanliness.
  2. More functionally, the above can create visual problems due to styling. If the container has a background color, border, or background images, and top/bottom padding, it will create a phantom box. The red rectangle below is produced by the following empty div:
    <div style="padding:10px 0;background-color:red;"></div>
  3. It is impossible to conditionalize content/markup for the widgetset's container. User may have call to apply a template's archive type as a class, for example.
  4. It is impossible to conditionalize content/markup for the widgets themselves. If the layout method being used requires something like first/last classes, this can't be accommodated. Same if any sort of alternation is needed for styling.

Features & Requirements

  1. A container tag for accessing a widget set's output, here referred as WidgetSetLoop.
    1. The container must support the template loop meta-variables.
    2. It would be nice if this included __size__ , requested in Fbz case 79738.
    3. The container should support the "glue" argument.
  2. A tag that outputs the current widget's content, here referred as WidgetContent. This tag would be functionally equivalent to <$mt:Include widget="WidgetName" [etc.]$>.
    1. This tag should support the passing of parameters, as with Include.
    2. Alternately, to avoid duplicating functionality, this tag could be left out and template authors just use Include. (Downsides?)
  3. <$mt:WidgetSetLabel$> - label of widget set
  4. <$mt:WidgetLabel$> - label of widget
  5. Header/Footer containers(eg. EntriesHeader) are explicitly NOT required; this functionality should be implemented using the above meta-variables.
  6. The existing WidgetSet tag remains; it's perfectly fine for its use case as a convenience tag, where fine-grained control is not needed.

Tag Examples

This would allow for the following more robust usage:

<mt:WidgetSetLoop name="someset">
<mt:If name="__first__"><div id="my-widgetset"></mt:If>
<div class="widget<mt:If name="__first__"> first<mt:ElseIf name="__last__"> last</mt:ElseIf></mt:if>">
<$mt:WidgetContent$>
</div>
<mt:If name="__last__"></div></mt:If>
</mt:WidgetSetLoop>

Another example:

<mt:WidgetSetLoop name="My Widget Set">
    <mt:If name="__first__"><div id="<$mt:WidgetSetLabel dirify="1"$>"></mt:If>
<div class="widget<mt:If name="__first__"> first<mt:Else name="__last__"> last</mt:if> <$mt:WidgetLabel dirify="1"$>">
    <h3><$mt:WidgetLabel$></h3>
    <$mt:WidgetContent$>
</div>
    <mt:If name="__last__"></div></mt:If>
</mt:WidgetSetLoop>

Related Bugs

Initial Fbz feature request, referring here for detail.