Ad

How To Generate The Pagination Links In Fluid By Myself

- 1 answer

I have an TYPO3 extension which shows a list of records. As it are more than 40 pages I would like to provide an additional alphabetic index which enables visitors to jump directly to the beginning of a character.

In general all is working - except the link to the n-th page.

I have the fluid variables cur containing current character (e.g. M) and the necessary page number in pageNumber (e.g. 23).

How can I get the correct url which should look like: https://mydomain.tld/path/to/list?tx_myextension_myextension[@widget_0][currentPage]=23&cHash=a6193a7eab129df4789343911221584b#jumplabel_M

either

<a class="page-link" href="{f:uri.page(additionalParams:{tx_myextension_myextension{@widget_0:{currentPage:pageNumber}}})}#jmplabel_{cur}">{cur}</a>

nor

<a class="page-link" href="{f:uri.page(additionalParams:{tx_myextension_myextension[@widget_0][currentPage]:pageNumber})}#jmplabel_{cur}">{cur}</a>

call the f:uri.page VH. The result is an unreplaced string in the href-parameter.


<a class="page-link" href="{f:uri.page()}?tx_phonebook_phonebook[@widget_0][currentPage]={pageNumber}#jmplabel_{cur}">{cur}</a>

looks ok, but misses the cHash and therefore results in 404 page not found.

Ad

Answer

Check how Georg Ringer does it in his News extension. Actually that's a solution for your pagination.

PaginateAdditionalParamsViewHelper.php:
https://github.com/georgringer/news/blob/master/Classes/ViewHelpers/Widget/Ajax/PaginateAdditionalParamsViewHelper.php#L30

public function render()
{
    $page = (int)$this->arguments['page'];
    if ($page === 0) {
        return [];
    }
    $params = [
        'tx_news_pi1' => [
            '@widget_0' => [
                'currentPage' => $page
            ]
        ]
    ];

    return $params;
}

And in some template:
https://github.com/georgringer/news/blob/master/Resources/Private/Templates/Styles/Twb/Templates/ViewHelpers/Widget/Paginate/IndexAjax.html#L56, especially additionalParams key.

<f:widget.link data="{container:recordId,link:'{t:uri.ajaxAction(contextRecord:\'tt_content:{recordId}\', pluginName: \'pi1\',additionalParams:\'{n:widget.ajax.paginateAdditionalParams(page:0)}\')}'}">
    <f:translate key="paginate_previous" />
</f:widget.link>
Ad
source: stackoverflow.com
Ad