문제

I'm using a pagination example from balbus design. In the .ss template, there is a line of code:

<% control ProductList.PaginationSummary(5) %>

Is that possible to use a variable instead of hard-coding the value 5? For example:

<% control ProductList.PaginationSummary(PSSize) %>

The variable PSSize is defined in the model and will return the number set in the CMS.

도움이 되었습니까?

해결책

The SS 2.4 templating language is very limited in terms of what it can do.

In this specific case, you could try working it out in the controller - try adjusting the $resultSet within ProductListPage_Controller::ProductList to preprocess the pagination summary to desired context size, so you can access it later from the template.

Try something like that:

$resultSet->AdjustedPaginationSummary = $resultSet->PaginationSummary($this->productsPerPage);
return $resultSet;

And then in the template you should be able to do:

<% control ProductList.AdjustedPaginationSummary %>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top