Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WidgetHolder template seems to be clueless of loop figures #121

Closed
lhasselb opened this issue Feb 18, 2016 · 1 comment
Closed

WidgetHolder template seems to be clueless of loop figures #121

lhasselb opened this issue Feb 18, 2016 · 1 comment

Comments

@lhasselb
Copy link

If I am not wrong the WidgetHolder.ss template is used within the WidgetArea.ss template to wrap the Widgets added to a page:
Here is the WidgetArea.ss

<% loop WidgetControllers %>
    $WidgetHolder
<% end_loop %>

and the WidgetHolder.ss:

<div class="WidgetHolder $ClassName<% if FirstLast %> $FirstLast<% end_if %>">
    <% if Title %><h3>$Title</h3><% end_if %>
    $Content
</div>

But if I add $Pos or $TotalItems to the latter the value for both position indicators is always 1 (for all Widgets added - I added 3). This came to my attention because the line

<% if FirstLast %> $FirstLast<% end_if %>

added "first last" every time (in my case for all 3 Widgets).

The documentation points out
$FirstLast: Returns a string, "first", "last", "first last" (if both), or "". Useful for CSS classes.

If it is intended like that how should the logic for
<% if FirstLast %> $FirstLast<% end_if %>
work?

@tractorcow
Copy link
Contributor

It's because the $WidgetHolder creates a new context, one where the current iterator is NOT available.

You need to add the iterator-specific variables into the top level template.

<% loop WidgetControllers %>
    <div class="<% if FirstLast %> $FirstLast<% end_if %>">
        $WidgetHolder
    </div>
<% end_loop %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants