3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 656 Views |
-
Control Loop not being interpreted properly by template builder

26 April 2011 at 9:54am
I have a control loop in a template - it's used for looping through the pagination summary for a DataObject set. Its pretty simple and works in other contexts. However in this situation it breaks i.e.
The section of the template file looks like this:
<% control StemData.Comments.PaginationSummary(4) %>
<!-- Do Stuff Here -->
<% end_control %>The template section it builds looks like this:
<% control StemData.Comments.PaginationSummary(4) %>
<!-- Do Stuff Here -->
SSVIEWER;
} ;
$val .= <<<SSVIEWERHowever it should be converting it to something like this:
SSVIEWER;
array_push($itemStack, $item); if(($loop = $item->obj("StemData",null,true)->obj("Comments",null,true)) && ($loop = $loop->obj("PaginationSummary", array("4")))) foreach($loop as $key => $item) { ;
$val .= <<<SSVIEWER
<!-- Do Stuff Here -->
SSVIEWER;
} ;
$val .= <<<SSVIEWERIf I manually change it to what it should be and re-upload the cache template file the page loads fine - if I let it build it automatically it fails to make a functional template in the cache and I get:
<b>Parse error</b>: syntax error, unexpected '}' in ...
Any ideas - am I doing something wrong or is this a bug
-
Re: Control Loop not being interpreted properly by template builder

26 April 2011 at 11:03am
This is because SSViewer can't handle that particular syntax. If you replace <% control StemData.Comments.PaginationSummary(4) %> with <% control StemData %><% control Comments.PaginationSummary(4) %>, then have two <% end_control %>s, it should work.
-
Re: Control Loop not being interpreted properly by template builder

26 April 2011 at 11:38am
Thanks, that worked.
Its good to know that there is a nesting limit of one layer for control loops.
- Just a comment if any of the devs read this -
It does however seem a little inconsistent to me for there to be a nesting limit of one layer for control loops when you can access more deeply nested properties like Object.DataObjectSet.PrevLink etc directly without using <% control %>
Would be nice if it were more consistent...
as this works for $Page_Controller->DataObjectSet:
<% control DataObjectSet.PaginationSummary(4) %>
<!-- Do Stuff Here -->
<% end_control %>And so does this for $Page_Controller->Object->DataObjectSet:
<% control Object %>
<% control DataObjectSet.PaginationSummary(4) %>
<!-- Do Stuff Here -->
<% end_control %>
<% end_control %>but this doesn't for $Page_Controller->Object->DataObjectSet:
<% control Object.DataObjectSet.PaginationSummary(4) %>
<!-- Do Stuff Here -->
<% end_control %> -
Re: Control Loop not being interpreted properly by template builder

26 April 2011 at 8:29pm
This was a limitation of the regex based SSViewer in 2.4 > (all methods had to be a separate expression). In the SSViewer rewrite (3.0 or master on github) this restriction should no longer apply.
| 656 Views | ||
|
Page:
1
|
Go to Top |


