Discussion:
[TYPO3-english] pagebrowse
Robert Wildling
2012-05-03 13:11:50 UTC
Permalink
Hi,
I am one of those newbies in EXT development. Digging through Dmitiris
book and tons of google results, I am still too unexperienced to be able
to handle the pagebrowse extension and what the manual says.

Can anybody please point me to a step-by-step tutorial of how to
implement Dmitiris pagebrowse - or even the TYPO3-regular one from the
piBase? I really don't know how to search anymore...

Thank you!
Regards,
Robert
Victor Livakovsky
2012-05-04 09:08:26 UTC
Permalink
Hi, Robert.
Can anybody please point me to a step-by-step tutorial of how to implement
Dmitiris pagebrowse - or even the TYPO3-regular one from the piBase? I
really don't know how to search anymore...
Simply use code of method 'getListGetPageBrowser()' from manual and pass
number of pages as reference. You can calculate number of pages, by
selecting count of your records and dividing it to number of results per
page.
Really simple.
Robert Wildling
2012-05-04 12:56:11 UTC
Permalink
Well... really simple ... probably for an experienced EXT developer, but
not for a newbie. EG: where is one expected to put that code snippet of
getListGetPageBrowser?
When I put it in my pi1-class, I get an error about some undefined
class. But pagebrowse is installed, and - if I understand the code
correctly, I do not have to include anymore classes at the top of my
extention class, right?

Thanks so much for your feedback - I hope you stick with me for a little
while! Also, did you by any chance have the possibility to text
pagebrowse on TYPO3 4.6.*? Because the installer says it is only allowed
to install until v4.5.9 ...???

Cheers!
Robert
Post by Victor Livakovsky
Hi, Robert.
Post by Robert Wildling
Can anybody please point me to a step-by-step tutorial of how to
implement Dmitiris pagebrowse - or even the TYPO3-regular one from the
piBase? I really don't know how to search anymore...
Simply use code of method 'getListGetPageBrowser()' from manual and pass
number of pages as reference. You can calculate number of pages, by
selecting count of your records and dividing it to number of results per
page.
Really simple.
Victor Livakovsky
2012-05-04 13:46:51 UTC
Permalink
Hi, Robert.
Post by Robert Wildling
Well... really simple ... probably for an experienced EXT developer, but
not for a newbie. EG: where is one expected to put that code snippet of
getListGetPageBrowser?
When I put it in my pi1-class, I get an error about some undefined class.
But pagebrowse is installed, and - if I understand the code correctly, I
do not have to include anymore classes at the top of my extention class,
right?
Okay...
Yes, you shouldn't include any other class.

Your pi-class should look like this:
class tx_myext_pi1 extends tslib_pibase {
...
}

Put inside that method (getListGetPageBrowser).
/**
* Gets list of pages from 'pagebrowse' ext.
*
* @return string Pagebrowser's content.
* @param int $numberOfPages Full number of pages.
* @param string $pageVar Name of 'page' in piVars.
*/
function getListGetPageBrowser($numberOfPages, $pageVar = 'page' ) {

$conf =
$GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_pagebrowse_pi1.'];

$conf['pageParameterName'] = $this->prefixId . '|'. $pageVar;
$conf['numberOfPages'] = $numberOfPages;
$conf['disableCacheHash'] = 1;

$cObj = t3lib_div::makeInstance('tslib_cObj');
/* @var $cObj tslib_cObj */
$cObj->start(array(), '');
return $cObj->cObjGetSingle('USER_INT', $conf);
}

In your main() method you may do this:
$recordsList = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($select, $from,
$where, $groupBy, $orderBy, $limit);
$fullRecCount = count($recordsList );
$recordsList = array_slice($recordsList, $this->piVars['page'] *
$this->conf['listView.']['limit'], $this->conf['listView.']['limit']);

First line selects records from db and puts them into array (you mey read
more about db related TYPO3 functions by looking inside t3lib/t3lib_db.php
class).
Second line finds quantity of all the records (if you didn?t set limit,
obviously).
Third line gets that piece of records, that are requested by user, using
pagebrowser. Current page number is stored in $this->piVars['page'],
$this->conf['listView.']['limit'] takes amount of records per page from TS
of your extension (you should, probably, know, how to set some TS options
for extensions).

After that you may do the output:
foreach($announcementsList as $announcement) {
// your code, that makes output of every record comes here
}

And finally you call your pagebrowser method:
$this-> content .= $this->getListGetPageBrowser(ceil($fullRecCount /
$this->conf['listView.']['limit']));


And surely, best practice is to:
1) Play with extension kickstarter to see, what basic options are offered by
TYPO3 API.
2) Read official API documents.
3) Look at other similar to yours extensions code to see, what methods do
authors use and how do they use them.
4) Look at TYPO3 source code (Dmitry's book already gives directions, what
to read).

Good luck!

Loading...