This goes on the beginning of the main php file. it defines the navigation object:
Code: Select all
$limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', 10 );
$limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 );
$rows = array();
$dbdest->setQuery( "SELECT COUNT(*) FROM #__destaques" );
$total = $dbdest->loadResult();
$pageNav = new mosPageNav( $total, $limitstart, $limit );
and this is the function that loads the item listing:
Code: Select all
function listDestaques( $option )
{
global $mainframe, $my;
global $mosConfig_live_site;
global $Itemid;
global $dbdest, $pageNav;
global $mosConfig_list_limit;
$query = "SELECT id, url, title, description, date, hits, params, ordering, published, checked_out"
. "\n FROM #__destaques"
. "\n ORDER BY ordering"
. "\n LIMIT $pageNav->limitstart,$pageNav->limit"
;
$dbdest->setQuery( $query );
$rows = $dbdest->loadObjectList();
$menu = new mosMenu( $dbdest );
$menu->load( $Itemid );
$params = new mosParameters( $menu->params );
$params->def( 'page_title', 1 );
$params->def( 'header', $menu->name );
$params->def( 'pageclass_sfx', '' );
$params->def( 'headings', 1 );
$params->def( 'hits', $mainframe->getCfg( 'hits' ) );
$params->def( 'item_description', 1 );
$params->def( 'other_cat_section', 1 );
$params->def( 'other_cat', 1 );
$params->def( 'description', 1 );
$params->def( 'description_text', _WEBLINKS_DESC );
$params->def( 'image', '-1' );
$params->def( 'destaque_icons', '' );
$params->def( 'image_align', 'right' );
$params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
$tabclass = array( 'sectiontableentry1', 'sectiontableentry2' );
HTML_destaques::displaylist( $rows, $params, $tabclass, $option, $pageNav );
}
Now, for the html part:
Some of the parameters necessary to use the methods that build the arrows and allow the reordering are defined here:
Code: Select all
for ($i=0, $n=count( $rows ); $i < $n; $i++)
{
$row = $rows[$i];
$iparams = new mosParameters( $row->params );
$link = sefRelToAbs( 'index.php?option=com_destaques&task=view&id='. $row->id );
I will not put the entire code of the displaylist method, because the pageNav isn't used in it, but passed as parameter to another method of the HTML class, called showTable, that build the rows with data, as follows:
Code: Select all
<td>
<?php echo $pageNav->orderUpIcon( $i, TRUE); ?>
</td>
<td colspan="2" align="center" class="<?php echo "row$k"; ?>">
</td>
<td>
<?php echo $pageNav->orderDownIcon( $i, $n, TRUE); ?>
</td>
As you could see, that was the code that built the arrow buttons, using as parameter those variables declared in the beginning of the loop.
The last instance of the pagenav object is here:
Code: Select all
$pageNav->getListFooter();
That one goes after the table of the displaylist form. And thats it...
I have compared it to the com_content code (backend), and (to me) the codes are all in the right places, but the resulting pagination is a mess. Only 1 item is listed at a time, the reordering is not working, it is a complete chaos. if someone who have experienced this or something close to it, or have a better knowing of the pageNav class and want to help, i will be very thankful!