Is it possible to change the limit of a loop, dynamically?
Would it require some PHP?
You can do it without using PHP. Here are two ways that come to mind, but I'm sure there are others.
Method 1: Using a segment variable
The following loop for a products listing will set a default limit of 10, but uses segment_2
to set a different limit dynamically.
{exp:channel:entries
channel="products"
disable="categories|category_fields|member_data"
limit="{if segment_2 != ''}{segment_2}{/if}{if segment_2 == ''}10{/if}"
dynamic="no"
paginate="bottom"
}
{title}<br>
{paginate}
<div>Page {current_page} of {total_pages} pages {pagination_links}</div>
{/paginate}
{/exp:channel:entries}
Then to allow the user to show a different number of results per page, you just provide some links like
<a href="/products/10">Show 10 results per page</a>
<a href="/products/20">Show 20 results per page</a>
etc (building your links according to your preferences). The pagination will continue to work, but with a different limit.
Method 2: Using a form, POST data, and Dynamic Parameters
{exp:channel:entries
channel="products"
disable="categories|category_fields|member_data"
limit="10"
dynamic="no"
paginate="bottom"
dynamic_parameters="limit"
}
{title}<br>
{paginate}
<div>Page {current_page} of {total_pages} pages {pagination_links}</div>
{/paginate}
{/exp:channel:entries}
<form method="post" action="/products">
<select name="limit">
<option value="10">Result Limit:</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>
<input type="submit" value="Go!" />
</form>