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:
- 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
I am already using this extension privately and I plan to migrate comments extension to use this page browser. So if you need a page browser in your extension, give pagebrowse a try. I am sure you will like it.
Comments
I will definitly test it soon!
Thanks in advance,
Stefan.
Thanks for this ext! I will give it a try with my new extensions like chgallery
One question: is there a way to get rid of the cHash parameter when you call the extension as USER_INT?
(By the way, you have some unfilled markers below the archive list to the right: \"###ARCHIVE_EMPTY_MSG### | ###COUNT###\"
I can\'t find some spezial help for my problem.. - Sorry that i ask here.
best regards and thx for the book (i\'m waiting for the german version)
alex
I\'m using your great pagebrowse extension and found a little bug in the postInit hook. You check the postInit hook is an array in line: 116 but iterate through the preInit hook in the next line.
Best regards
Jan Matthiesen
I just found a typo in the documentation:
http://typo3.org/documentation/document-library/extension-manuals/pagebrowse/1.0.1/view/1/5/
"pageParamName" should be "pageParameterName" as seen above.
Thanks again for your hard work to improve TYPO3!
protected $numberOfPages;
protected $pageParameterName;
protected $currentPage;
protected $pagesBefore = 3;
protected $pagesAfter = 3;
are all protected, so the hooks postInit and preInit are pretty much useless now.
is there an API planned for the variables??
In my case I need to 'inject' the page number to a different page then pagebrowse things is correct.
Ries
function main(...) {
// Number of list items per page
$itemsPerPage = 16
// example array of list items
$items = array('all', 'my', '1001', '...', 'items');
// split array into chunks
$items = array_chunk($items, $itemsPerPage);
// How much pages do we need
$numberOfPages = count($data);
// render the specific part of the list
$content = t3lib_div::view_array($items[intval($this->piVars['page'])]);
// Add page browser
$content .= $this->getListGetPageBrowser($numberOfPages);
return $content;
}
i have followed the instructions in the manual and have set up everything as described/needed (i'm using templavoila) but when i try to "Either set a page to the doktype “Pagebrowser” or set the field “Contains plugin” in the page properties to “Pagebrowser”." i have no Pagebrowser options in these two popups.
using t3 4.2.9
<!--
BEGIN: Content of extension "pagebrowse", plugin "tx_pagebrowse_pi1"
-->
<div class="tx-pagebrowse-pi1">
</div>
<!-- END: Content of extension "pagebrowse", plugin "tx_pagebrowse_pi1" -->
what am i doing wrong?
Submitted a report in forge for an error in the plugin.
i have installed t3blog 0.8.1. and pagebrowse 1.1.0
How can I changed the language into german? Following code in the setup does´nt work:
plugin.tx_t3blog_pi1._LOCAL_LANG.de.{
pi_list_browseresults_prev = <Zurück
pi_list_browseresults_page = Seite
pi_list_browseresults_next = Nächste >
pi_list_browseresults_first = << Erste
pi_list_browseresults_last = Letzte >>
}
thank you for help
simon
goto Extension Manager -> Translation handling. Select "German" and press "Update from Repository".
Now the language files will be updated and your pagebrowser should be in German.
I've just done it right now.
Alexander
thx a lot. That was what I was looking for too.
Very useful plugin and works perfect for me. I used it in my extension, and it is amazing that it take now couple lines for ready to use page browser.
Thank you,
Stas
ToDo-List:
1. Include »pagebrowse« basis TypoScript in your root-template
2. Add a marker ###PAGEBROWSER### to your own extension template file (HTML template)
3. Add the example method provided by
Do this, then include the example method provided by Dmitry (i changed some lines, since i got an error -> displayErrors in your TYPO3 Installation)
4. Call the method and fill a marker with the returned value (see example in comment made by Steffen Müller)
i followed the instructions from Daniel
the method said in Point 3 is this right?
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);
}
What does he mean after that with the sample method by Dmitry?
In the Example made by Steffen, i don't understand what he mean by:
$numberOfPages = count($data); --> What is $data?
Steffen uses this as items:
$items = array('all', 'my', '1001', '...', 'items');
i have already a multidimensional array of items. How can i take them as items?
Thx.
Thx anyway.
Add a comment
All fields in this form are required!