I have one for you! Yesterday I uploaded the first version of the "Universal page browser" extension into TER. This extension provides page browsing services to other extensions.
Currently extensions either use their own home made page browser or use default from tslib_pibase. Neither of these solutions is good. Home made page browsers requires time to create and also to maintain. It takes space in the code. The default one is hard to configure, it is not flexible for any modern application. In addition it is table–based, which is not how HTML code should be made these days.
Recently I had to write my own page browser three times in three different extensions and twice used the default one. All these times it was loss of time. If I had a "normal" page browser, I could save on development and debugging.
Armed with this idea I decided to make a page browser that I could use in any other project. I started developing it and then there came one of Netcreators projects, where I could finish this development.
As a result I made a new extension that any other extension case use to integrate a modern highly customizable CSS-based page browser. It is very easy to use. Here is the code:
protected function getListGetPageBrowser($numberOfPages) {
// Get default configuration
$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_pagebrowse_pi1.'];
// Modify this configuration
$conf += array(
'pageParameterName' => $this->prefixId . '|page',
'numberOfPages' => intval($numberOfPages/$this->conf['pageSize']) +
(($numberOfPages % $this->conf['pageSize']) == 0 ? 0 : 1),
);
// Get page browser
$cObj = t3lib_div::makeInstance('tslib_cObj');
/* @var $cObj tslib_cObj */
$cObj->start(array(), '');
return $cObj->cObjGetSingle('USER', $conf);
}
It is 7 lines (without comments) to get a fully functional page browser for your extension. It provides a tx_yourextkey_pi1[whatevervar] to your extension, takes care about caches, etc. Here is a feature list:
Currently extensions either use their own home made page browser or use default from tslib_pibase. Neither of these solutions is good. Home made page browsers requires time to create and also to maintain. It takes space in the code. The default one is hard to configure, it is not flexible for any modern application. In addition it is table–based, which is not how HTML code should be made these days.
Recently I had to write my own page browser three times in three different extensions and twice used the default one. All these times it was loss of time. If I had a "normal" page browser, I could save on development and debugging.
Armed with this idea I decided to make a page browser that I could use in any other project. I started developing it and then there came one of Netcreators projects, where I could finish this development.
As a result I made a new extension that any other extension case use to integrate a modern highly customizable CSS-based page browser. It is very easy to use. Here is the code:
protected function getListGetPageBrowser($numberOfPages) {
// Get default configuration
$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_pagebrowse_pi1.'];
// Modify this configuration
$conf += array(
'pageParameterName' => $this->prefixId . '|page',
'numberOfPages' => intval($numberOfPages/$this->conf['pageSize']) +
(($numberOfPages % $this->conf['pageSize']) == 0 ? 0 : 1),
);
// Get page browser
$cObj = t3lib_div::makeInstance('tslib_cObj');
/* @var $cObj tslib_cObj */
$cObj->start(array(), '');
return $cObj->cObjGetSingle('USER', $conf);
}
It is 7 lines (without comments) to get a fully functional page browser for your extension. It provides a tx_yourextkey_pi1[whatevervar] to your extension, takes care about caches, etc. Here is a feature list:
- Custom templates are possible
- Default CSS–based template available
- Customizable number of pages before current and after
- The following links can be generated (or switched off):
- First page
- Previous page
- Next page
- Last page
- There can be indicators that there are more or less pages available that numeric links show (can be switched off)
- Extensions can add extra query parameters to the generated page link. These parameters can be generated automatically from TS template using stdWrap
- Current query string is automatically appended to the page link
- cHash is properly generated
- First page does not have a page parameter, which prevents double content issue (SEO–related)
- Full detailed manual with all options explained
Hello dimitry,
ReplyDeleteI am currently using your pagebrowser in comments, and the page is multilingual.
Now I am trying to change the wordung of e.g. " < Last>>" for the protuguese language and am failing...
I tried things like the following without changing anything:
plugin.tx_pagebrowse_pi1 {
_LOCAL_LANG.default{
text_no_comments = Sem comentários
text_first = Primeiro
text_prev = Anterior
text_next = Seguinte
text_last = Último
}
}
do you have any idea how to get this done?
Thanks,
Emil
Hi, Emil. I never used the method with _LOCAL_LANG, so I am not sure. You could simply copy html template and put strings there. Than use TS conditions to change the template:
ReplyDelete[globalVar = GP:L=1]
plugin.tx_pagebrowse_pi1.templateFile = ....
[global]
Is it just me or is the wording used in here and in the TER docs really off?
ReplyDeleteShouldn't the name of the variable $numberOfPages rather be $numberOfResults? This one made me stumble and even look through your source code if I misunderstood some basic thing.