ability to hide first/last links on pagination bar #357

Closed
opened 2026-10-04 23:53:45 +02:00 by adam · 11 comments
Owner

Sometimes it's useless and we don't want to have such a "full featured" pagination bar.

Sometimes it's useless and we don't want to have such a "full featured" pagination bar. <!-- github-sync-id:110641955 -->
adam closed this issue 2026-10-04 23:53:45 +02:00
Author
Owner

Isn't this more of a thing that themes/templates can handle?

Isn't this more of a thing that themes/templates can handle? <!-- github-comment-id:177765878 -->
Author
Owner

@eberkund no it's not because pagination bar is generated in include/functions.inc.php create_navigation_bar()

@eberkund no it's not because pagination bar is generated in include/functions.inc.php create_navigation_bar() <!-- github-comment-id:182475544 -->
Author
Owner

The function renders html ? If yes thus should be changed to let smarty render it. The function only generates the pages list

The function renders html ? If yes thus should be changed to let smarty render it. The function only generates the pages list <!-- github-comment-id:182483380 -->
Author
Owner

Actually I'm half wrong. The rendering is done in Smarty:

$ find . -name navigation_bar.tpl
./stripped_black_bloc/template/navigation_bar.tpl
./simple/template/navigation_bar.tpl
./stripped/template/navigation_bar.tpl
./default/template/navigation_bar.tpl
./luciano/template/navigation_bar.tpl
./stripped_responsive/template/navigation_bar.tpl
./bootstrapdefault/template/navigation_bar.tpl
./smartpocket/template/navigation_bar.tpl

So even if we add a configuration setting, themes will have to implement it as well. So it's also a "theme issue". It's more complex than I thought (and the feature is not important).

Actually I'm half wrong. The rendering is done in Smarty: $ find . -name navigation_bar.tpl ./stripped_black_bloc/template/navigation_bar.tpl ./simple/template/navigation_bar.tpl ./stripped/template/navigation_bar.tpl ./default/template/navigation_bar.tpl ./luciano/template/navigation_bar.tpl ./stripped_responsive/template/navigation_bar.tpl ./bootstrapdefault/template/navigation_bar.tpl ./smartpocket/template/navigation_bar.tpl So even if we add a configuration setting, themes will have to implement it as well. So it's also a "theme issue". It's more complex than I thought (and the feature is not important). <!-- github-comment-id:182485402 -->
Author
Owner

The idea would be to simply add an "if" statement in the template, like:

{if $conf.paginate_show_first_last}{/if}

but it would only work on themes which implements it or themes that rely on the default navigation_bar.tpl

The idea would be to simply add an "if" statement in the template, like: {if $conf.paginate_show_first_last}{/if} but it would only work on themes which implements it or themes that rely on the default navigation_bar.tpl <!-- github-comment-id:182487105 -->
Author
Owner

@plegall But won't that function only be run if a theme calls it?

What is the problem with displaying it based only on if it is in the template or not?

@plegall But won't that function only be run if a theme calls it? What is the problem with displaying it based only on if it is in the template or not? <!-- github-comment-id:182495141 -->
Author
Owner

Themes don't really call the function create_navigation_bar(). This function is called in index.php (for example) to generate the navigation bar for thumbnails. index.php adds it to the template variables. Then the template file navigation_bar.tpl looks for the appropriate template variable to build HTML code.

The idea is to have this feature "configurable" in Piwigo core. Then themes (thanks to template files) can implement it or not. A theme can perfectly decide to remove page numbers and only display prev/next as pagination bar. It doesn't mean all users of this theme will like it that way.

Themes don't really call the function create_navigation_bar(). This function is called in index.php (for example) to generate the navigation bar for thumbnails. index.php adds it to the template variables. Then the template file navigation_bar.tpl looks for the appropriate template variable to build HTML code. The idea is to have this feature "configurable" in Piwigo core. Then themes (thanks to template files) can implement it or not. A theme can perfectly decide to remove page numbers and only display prev/next as pagination bar. It doesn't mean all users of this theme will like it that way. <!-- github-comment-id:182502670 -->
Author
Owner

hi guys
"The idea is to have this feature "configurable" in Piwigo core" again one config/var for such detail... I would rather prefer to see it as a pure theme config
what about something like


<div class="navigationBar">
{ if $navbar.pages|@count < 5}
{******** only displays number of pages if there is not so much pages *****************}
 {foreach from=$navbar.pages key=page item=url}
    {if $page == $navbar.CURRENT_PAGE}
    <span class="current">{$page}</span>
    {else}
    <a href="{$url}">{$page}</a>
    {/if}
    {assign var='prev_page' value=$page}
  {/foreach}
{else}
{********************* else display first/last and ... ***********************}
  {if isset($navbar.URL_FIRST)}
  <a href="{$navbar.URL_FIRST}" rel="first">{'First'|@translate}</a> |
  <a href="{$navbar.URL_PREV}" rel="prev">{'Previous'|@translate}</a> |
  {else}
  {'First'|@translate} |
  {'Previous'|@translate} |
  {/if}

  {assign var='prev_page' value=0}
  {foreach from=$navbar.pages key=page item=url}
    {if $page > $prev_page+1}...{/if}
    {if $page == $navbar.CURRENT_PAGE}
    <span class="pageNumberSelected">{$page}</span>
    {else}
    <a href="{$url}">{$page}</a>
    {/if}
    {assign var='prev_page' value=$page}
  {/foreach}

  {if isset($navbar.URL_NEXT)}
  | <a href="{$navbar.URL_NEXT}" rel="next">{'Next'|@translate}</a>
  | <a href="{$navbar.URL_LAST}" rel="last">{'Last'|@translate}</a>
  {else}
  | {'Next'|@translate}
  | {'Last'|@translate}
  {/if}
</div>
hi guys "The idea is to have this feature "configurable" in Piwigo core" again one config/var for such detail... I would rather prefer to see it as a pure theme config what about something like ``` <div class="navigationBar"> { if $navbar.pages|@count < 5} {******** only displays number of pages if there is not so much pages *****************} {foreach from=$navbar.pages key=page item=url} {if $page == $navbar.CURRENT_PAGE} <span class="current">{$page}</span> {else} <a href="{$url}">{$page}</a> {/if} {assign var='prev_page' value=$page} {/foreach} {else} {********************* else display first/last and ... ***********************} {if isset($navbar.URL_FIRST)} <a href="{$navbar.URL_FIRST}" rel="first">{'First'|@translate}</a> | <a href="{$navbar.URL_PREV}" rel="prev">{'Previous'|@translate}</a> | {else} {'First'|@translate} | {'Previous'|@translate} | {/if} {assign var='prev_page' value=0} {foreach from=$navbar.pages key=page item=url} {if $page > $prev_page+1}...{/if} {if $page == $navbar.CURRENT_PAGE} <span class="pageNumberSelected">{$page}</span> {else} <a href="{$url}">{$page}</a> {/if} {assign var='prev_page' value=$page} {/foreach} {if isset($navbar.URL_NEXT)} | <a href="{$navbar.URL_NEXT}" rel="next">{'Next'|@translate}</a> | <a href="{$navbar.URL_LAST}" rel="last">{'Last'|@translate}</a> {else} | {'Next'|@translate} | {'Last'|@translate} {/if} </div> ``` <!-- github-comment-id:182582111 -->
Author
Owner

Your idea to show only page numbers when there is less than 5 pages is nice (it could be nice for default navigation_bar.tpl)

I would rather prefer to see it as a pure theme config

So it would mean you have to change theme to get the navigation bar you want?

Another solution could be to just have specific CSS class on navigation bar links. Making it easy to hide with a CSS rule.

Another solution could be to have a plugin to replace navigation_bar.tpl, with an admin page for options and so on.

Actually I wanted this to be super easy so that I can implement it in Piwigo 2.8. Obviously it's not that "easy" ;-) I'm simply going to add CSS class on first/last links on default navigation_bar.tpl.

Your idea to show only page numbers when there is less than 5 pages is nice (it could be nice for default navigation_bar.tpl) > I would rather prefer to see it as a pure theme config So it would mean you have to change theme to get the navigation bar you want? Another solution could be to just have specific CSS class on navigation bar links. Making it easy to hide with a CSS rule. Another solution could be to have a plugin to replace navigation_bar.tpl, with an admin page for options and so on. Actually I wanted this to be super easy so that I can implement it in Piwigo 2.8. Obviously it's not that "easy" ;-) I'm simply going to add CSS class on first/last links on default navigation_bar.tpl. <!-- github-comment-id:182775534 -->
Author
Owner

that's not that "easy" because it's asking a again the question of where we do what (I could argue again about template extensions :) :) which could do that if they were handled like plugins; no options page just switching on/off the TE )

So it would mean you have to change theme to get the navigation bar you want?

It depends on how well themes are updated. If we think theoretically/ideologically that would to the themes to manage that, but from a pragmatic point of view, a plugin would do the job better since the navigation bar is almost the same everywhere and theme developers wouldn't have to do the efforts

that's not that "easy" because it's asking a again the question of where we do what (I could argue again about template extensions :) :) which could do that if they were handled like plugins; no options page just switching on/off the TE ) > So it would mean you have to change theme to get the navigation bar you want? It depends on how well themes are updated. If we think theoretically/ideologically that would to the themes to manage that, but from a pragmatic point of view, a plugin would do the job better since the navigation bar is almost the same everywhere and theme developers wouldn't have to do the efforts <!-- github-comment-id:182879832 -->
Author
Owner

I don't want to restart a discussion about template-extension. They are too complicated. Plugins can do the same job and avoid failure after upgrade.

I will implement the request "the easy way" for 2.8 but if someone wants to propose a "smart navigation bar" as plugin, it would make some users happy :-) Again, I think it's really a minor feature.

I don't want to restart a discussion about template-extension. They are too complicated. Plugins can do the same job and avoid failure after upgrade. I will implement the request "the easy way" for 2.8 but if someone wants to propose a "smart navigation bar" as plugin, it would make some users happy :-) Again, I think it's really a minor feature. <!-- github-comment-id:182884146 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#357