Pagination in Module

880 views
Skip to first unread message

rnick

unread,
Nov 21, 2011, 11:13:12 AM11/21/11
to joomla-de...@googlegroups.com
Hi,

i'm writing a module in J1.7 to list addresses in the frontend and sticking on pagination. Is it possible to use pagination in a module? If i select the listlimit, the list shows only i.e. 5 Items, as selected. But on selecting 'next', the list shows complete.

thanks
Ralf

mod_addresses.php
---
jimport('joomla.html.pagination');

require_once(dirname(__FILE__) . DS . 'helper.php');

// get address data
$data = modAddressesHelper::getList($params);
$list = modAddressesHelper::getData($data);

$limitstart = JRequest::getInt('limitstart', 0);
$limit = JRequest::getInt('limit', 0);
JRequest::setVar('limitstart', $limitstart);
JRequest::setvar('limit', $limit);

$pageNav = new JPagination(count($data), $limitstart, $limit);

require JModuleHelper::getLayoutPath('mod_addresses',
    $params->get('layout', 'default'));


-------------------------
tmpl/default.php
<form action="index.php" name="admodform">   
<?php if (!empty($list)) : ?>
<ul class="archive-module<?php echo $moduleclass_sfx; ?>">
    <?php foreach ($list as $item) {
                                                          ?>
        <li><?php echo $item->name; ?></li>
       
        <?php
    }
 ?>
</ul>
         <?php echo $pageNav->getListFooter(); ?>
<?php endif; ?>


</form>

Mark Dexter

unread,
Nov 21, 2011, 12:22:29 PM11/21/11
to joomla-de...@googlegroups.com
Normally modules are supposed to be small and light-weight. This normally doesn't include pagination. It sounds like you want a component. The controller part of a component gives you the ability to process user commands (like clicking on next button). Mark



--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/wGFhDLobpIcJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Ralf Nickel

unread,
Nov 22, 2011, 3:30:48 PM11/22/11
to joomla-de...@googlegroups.com
Hi Mark,

thank you, for you answere. It's just a list of contacts that i want to display, maybe some filters, but no big thing. Details are shown in a component. As the list can contain 100 addresses, i would use pagination.

ralf

elin

unread,
Nov 22, 2011, 4:25:04 PM11/22/11
to joomla-de...@googlegroups.com
The thing is, pagination usually implies a page load. You might thing about doing it with tabs (or similar) instead if that seems reasonable for the number of addresses you have. 

Elin

Mark Dexter

unread,
Nov 22, 2011, 4:26:31 PM11/22/11
to joomla-de...@googlegroups.com
Sounds like a component to me. Mark

On Tue, Nov 22, 2011 at 1:25 PM, elin <elin....@gmail.com> wrote:
The thing is, pagination usually implies a page load. You might thing about doing it with tabs (or similar) instead if that seems reasonable for the number of addresses you have. 

Elin

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/kQPvDvwzxigJ.

Mike Smith

unread,
Nov 22, 2011, 4:29:55 PM11/22/11
to joomla-de...@googlegroups.com
If he really want to do it this way it can be done in a module, but the data displaying and paging need to be ajax driven then it would work just fine.

Mike.

Swapnil Shah

unread,
Nov 22, 2011, 4:40:03 PM11/22/11
to joomla-de...@googlegroups.com
There would still be an issue of what is going to be receiving that information and sending something back. It would still require a component on the other end to retrieve the request and send the appropriate information back.

Neil

Mike Smith

unread,
Nov 22, 2011, 4:41:56 PM11/22/11
to joomla-de...@googlegroups.com
Not at all, just a dedicated service file that the module ajax calls, I do it all the time!

Stephen Brandon

unread,
Nov 22, 2011, 4:53:50 PM11/22/11
to joomla-de...@googlegroups.com
I was recently helping someone out with a situation like this one. We actually used the com_rokmodule component to return the contents of a module via AJAX. So, your module could have 2 modes, controlled by URL parameter:

1 - the basic module display, page 0
2 - page n, controlled by a specific URL parameter that's only used in the AJAX call.

The initial page load loads up the module in the normal way, and displays page 0. Hitting the "next page" link calls up com_rokmodule with a page parameter to load the next page of the module.

Now, com_rokmodule isn't written the way that I'd do it. I'd prefer that it used a "raw" datatype rather than going through index2.php which still gives the <head> section of the page. But it was sufficient for the purpose that we had for it and I was too lazy to rewrite it.

Anyway, the beauty of this approach is that you *can* actually have the minimal pagination logic inside the module itself. This seems pretty elegant and fairly clean to me.

Cheers,
Stephen

Ralf Nickel

unread,
Nov 24, 2011, 4:23:42 AM11/24/11
to joomla-de...@googlegroups.com
Hi,

Am 22.11.2011 22:29, schrieb Mike Smith:
> If he really want to do it this way it can be done in a module, but
> the data displaying and paging need to be ajax driven then it would
> work just fine.

yes, i think this approach is in the right direction. The breaking point
which i had not thougth of, is the page reload. So, if i display a
component in an ajax container, it solves both issues: reload and
pagination.

thanks
Ralf

Reply all
Reply to author
Forward
0 new messages