Search code examples
typo3fluidtx-news

Dropdown to change tx_news.settings.list.paginate.itemsPerPage and refresh page


I'm looking for a way to change dynamically the tx_news.settings.list.paginate.itemsPerPage of tx_news in FE. I would like the user to set the number of items in FE and the news will automatically refresh.

Can you give me some hint?


Solution

  • This can work out like this

    1st: adopt the template

    This will add a select with the options

    <select onchange="if (this.value) window.location.href=this.value">
        <option value="">default</option>
        <option value="{f:uri.action(action:'list',addQueryString:1,additionalParams:{count:2})}">2</option>
        <option value="{f:uri.action(action:'list',addQueryString:1,additionalParams:{count:5})}">5</option>
        <option value="{f:uri.action(action:'list',addQueryString:1,additionalParams:{count:10})}">10</option>
        <option value="{f:uri.action(action:'list',addQueryString:1,additionalParams:{count:20})}">20</option>
    </select>
    

    what is currently missing is a check on {settings.list.paginate.itemsPerPage} and add the selected attribute.

    2nd: add some TS

    [globalVar = GP:count = 2]
    plugin.tx_news.settings.list.paginate.itemsPerPage = 2
    config.linkVars = count
    [END]
    
    [globalVar = GP:count = 5]
    plugin.tx_news.settings.list.paginate.itemsPerPage = 5
    config.linkVars = count
    [END]
    
    [globalVar = GP:count = 10]
    plugin.tx_news.settings.list.paginate.itemsPerPage = 10
    config.linkVars = count
    [END]