-
-
Save amcosta/04b3a39ea7b912768706598740383a71 to your computer and use it in GitHub Desktop.
Revisions
-
SimonSimCity revised this gist
Jan 22, 2013 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,7 @@ * currentFilters (array) : associative array that contains the current route-arguments * currentPage (int) : the current page you are in * paginationPath (string) : the route name to use for links * showAlwaysFirstAndLast (bool) : Always show first and last link (just disabled) * lastPage (int) : represents the total number of existing pages #} {% spaceless %} @@ -32,6 +33,8 @@ {% for i in range(currentPage-nearbyPagesLimit, currentPage-1) if ( i > 0 ) %} <a href="{{ path(paginationPath, currentFilters|merge({page: i})) }}">{{ i }}</a> {% endfor %} {% elseif showAlwaysFirstAndLast %} <span class="disabled">Previous</span> {% endif %} <a href="{{ path(paginationPath, currentFilters|merge({ page: currentPage })) }}" @@ -51,6 +54,8 @@ {% endfor %} <a href="{{ path(paginationPath, currentFilters|merge({page: currentPage+1})) }}">Next</a> {% elseif showAlwaysFirstAndLast %} <span class="disabled">Next</span> {% endif %} </div> {% endif %} -
SimonSimCity revised this gist
Jan 22, 2013 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ {# Source: http://dev.dbl-a.com/symfony-2-0/symfony2-and-twig-pagination/ Updated by: Simon Schick <simonsimcity@gmail.com> Parameters: * currentFilters (array) : associative array that contains the current route-arguments * currentPage (int) : the current page you are in -
SimonSimCity revised this gist
Jan 22, 2013 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,16 +27,16 @@ {% endif %} {% for i in range(currentPage-nearbyPagesLimit, currentPage-1) if ( i > 0 ) %} <a href="{{ path(paginationPath, currentFilters|merge({page: i})) }}">{{ i }}</a> {% endfor %} {% endif %} <a href="{{ path(paginationPath, currentFilters|merge({ page: currentPage })) }}" class="active">{{ currentPage }}</a> {% if currentPage < lastPage %} {% for i in range(currentPage+1, currentPage + nearbyPagesLimit) if ( i <= lastPage ) %} <a href="{{ path(paginationPath, currentFilters|merge({page: i})) }}">{{ i }}</a> {% endfor %} {% if (lastPage - extremePagesLimit) > (currentPage + nearbyPagesLimit) %} @@ -47,8 +47,7 @@ <a href="{{ path(paginationPath, currentFilters|merge({page: i})) }}">{{ i }}</a> {% endfor %} <a href="{{ path(paginationPath, currentFilters|merge({page: currentPage+1})) }}">Next</a> {% endif %} </div> {% endif %} -
SimonSimCity created this gist
Jan 22, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ {# Parameters: * currentFilters (array) : associative array that contains the current route-arguments * currentPage (int) : the current page you are in * paginationPath (string) : the route name to use for links * lastPage (int) : represents the total number of existing pages #} {% spaceless %} {% if lastPage > 1 %} {# the number of first and last pages to be displayed #} {% set extremePagesLimit = 3 %} {# the number of pages that are displayed around the active page #} {% set nearbyPagesLimit = 2 %} <div class="pagination"> {% if currentPage > 1 %} <a href="{{ path(paginationPath, currentFilters|merge({page: currentPage-1})) }}">Previous</a> {% for i in range(1, extremePagesLimit) if ( i < currentPage - nearbyPagesLimit ) %} <a href="{{ path(paginationPath, currentFilters|merge({page: i})) }}">{{ i }}</a> {% endfor %} {% if extremePagesLimit + 1 < currentPage - nearbyPagesLimit %} <span class="sep-dots">...</span> {% endif %} {% for i in range(currentPage-nearbyPagesLimit, currentPage-1) if ( i > 0 ) %} <a href="{{ path(paginationPath, currentFilters|merge({page: i})) }}"><span style="color: green">{{ i }}</span></a> {% endfor %} {% endif %} <a href="{{ path(paginationPath, currentFilters|merge({ page: currentPage })) }}" id="active_page"><b>{{ currentPage }}</b></a> {% if currentPage < lastPage %} {% for i in range(currentPage+1, currentPage + nearbyPagesLimit) if ( i <= lastPage ) %} <a href="{{ path(paginationPath, currentFilters|merge({page: i})) }}"><span style="color: green">{{ i }}</span></a> {% endfor %} {% if (lastPage - extremePagesLimit) > (currentPage + nearbyPagesLimit) %} <span class="sep-dots">...</span> {% endif %} {% for i in range(lastPage - extremePagesLimit+1, lastPage) if ( i > currentPage + nearbyPagesLimit ) %} <a href="{{ path(paginationPath, currentFilters|merge({page: i})) }}">{{ i }}</a> {% endfor %} <a href="{{ path(paginationPath, currentFilters|merge({page: currentPage+1})) }}">Next</a> {% endif %} </div> {% endif %} {% endspaceless %}