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>
- 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.
- 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>
- 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.
- 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
- A container tag for accessing a widget set's output, here referred as WidgetSetLoop.
- The container must support the template loop meta-variables.
- It would be nice if this included __size__ , requested in Fbz case 79738.
- The container should support the "glue" argument.
- 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.]$>.- This tag should support the passing of parameters, as with Include.
- Alternately, to avoid duplicating functionality, this tag could be left out and template authors just use Include. (Downsides?)
-
<$mt:WidgetSetLabel$>- label of widget set -
<$mt:WidgetLabel$>- label of widget - Header/Footer containers(eg. EntriesHeader) are explicitly NOT required; this functionality should be implemented using the above meta-variables.
- 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.