Front End Pagination Problem

This forum is for reporting bugs in Joomla!. Please don't report problems with extensions in here.
Forum rules
Forum Rules
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
thlas77
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Mon Oct 19, 2009 10:25 am

Re: Front End Pagination Problem

Postby thlas77 » Wed Sep 01, 2010 4:31 pm

Hi guys,
Today, I'm very happy to found the solution to one of my old problem !! Thanks a lot.
I have updated my code, it works well except when I change the number of row to display !!
When I don't change it, I have an URL like this :
http://127.0.0.1/myproject/index.php/co ... &start=125
When I change the number of row to display, it becomes :
http://127.0.0.1/myproject/index.php/co ... ?start=100

Any idea why the URL changes ?
What should I do to solve the problem or what extra information do you need to better understand my problem ?
Thanks a lot
Thierry

Milbo
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Fri Aug 08, 2008 7:33 am

Re: Front End Pagination Problem

Postby Milbo » Wed Sep 15, 2010 6:51 pm

First, thanks to this thread, finally I got the pagination working, but....

I dont get the limit working in the FE. In the backend everything works fine. I use the same model in BE and FE, so I didnt expected any problems using it in the FE.

My problem is that my js says: "this.form is null Line 1", when I try to use selector which chooses the number of items to display.

I tried to add different js files via $document->addScript(JURI::base().'includes/js/joomla.javascript.js');

But I dont get it. Help would be very nice.

Thanks

naturalcrusader
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sun Feb 01, 2009 9:10 pm

Re: Front End Pagination Problem

Postby naturalcrusader » Wed Sep 15, 2010 7:46 pm

Milbo wrote:First, thanks to this thread, finally I got the pagination working, but....

I dont get the limit working in the FE. In the backend everything works fine. I use the same model in BE and FE, so I didnt expected any problems using it in the FE.

My problem is that my js says: "this.form is null Line 1", when I try to use selector which chooses the number of items to display.

Thanks


If you used the code I posted, then your form may have a different name and that's why its not working, can you post all the code you are using in reference to this issue?

Milbo
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Fri Aug 08, 2008 7:33 am

Re: Front End Pagination Problem

Postby Milbo » Wed Sep 15, 2010 11:05 pm

I just used billengle tipp to get the switching of the pages to work:

Code: Select all

//$limitstart = $mainframe->getUserStateFromRequest(JRequest::getVar('option').'.limitstart', 'limitstart', 0, 'int');
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');


I use this lines both in BE and FE:

Code: Select all

<?php echo $this->pagination->getListFooter(); ?>


I avoid to use your tip, because the component must work without changing corefiles. Or is it possible to extend the class?

Thanks for helping

naturalcrusader
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sun Feb 01, 2009 9:10 pm

Re: Front End Pagination Problem

Postby naturalcrusader » Wed Sep 15, 2010 11:56 pm

Milbo wrote:
I avoid to use your tip, because the component must work without changing corefiles. Or is it possible to extend the class?

Thanks for helping


I used my way because i wanted it to work. good luck

Milbo
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Fri Aug 08, 2008 7:33 am

Re: Front End Pagination Problem

Postby Milbo » Thu Sep 16, 2010 9:52 am

you maybe did not understand me. I mean your tip changing the core files of joomla, I didnt meant your tips in general. It is usefull to get a page working, with some component/module or plugin for a special site, but is not useable for a bigger component, which is already used by thousands of people.

And as I asked. Maybe it is possible to extend this class, even when there is no abstract tag in the class definition.

On the other hand, I wonder how the other 3rd party developers solve this problem, when it is part of the joomla core files?

naturalcrusader
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sun Feb 01, 2009 9:10 pm

Re: Front End Pagination Problem

Postby naturalcrusader » Thu Sep 16, 2010 2:59 pm

Milbo wrote:On the other hand, I wonder how the other 3rd party developers solve this problem, when it is part of the joomla core files?


they write their own

Milbo
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Fri Aug 08, 2008 7:33 am

Re: Front End Pagination Problem

Postby Milbo » Thu Sep 16, 2010 4:46 pm

poor solution by joomla then. There were several security patches since you posted your fix. Hmm annoying.

ampearlman
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Wed Jun 16, 2010 4:23 pm

Re: Front End Pagination Problem

Postby ampearlman » Thu Oct 14, 2010 5:33 am

This is a great fix to a very frustrating problem. To make sure the links behave as intended I suggest adding href="#" (to ensure you get a mouse pointer and for css), return false to the onclick call (to ensure the page doesn't jump to the top when the link is clicked) and class=\"pagenav\" (to make sure css is applied).

This line:

naturalcrusader wrote:

Code: Select all

return "\n<a title=\"".$item->text."\"  onclick=\"javascript: document.adminForm.limitstart.value=".$item->base."; document.adminForm.submit(); \" >".$item->text."</a>";


Becomes this:

Code: Select all

return "\n<a title=\"".$item->text."\" href=\"#\" onclick=\"javascript: document.adminForm.limitstart.value=".$item->base."; document.adminForm.submit();return false; \" class=\"pagenav\">".$item->text."</a>";

Milbo
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Fri Aug 08, 2008 7:33 am

Re: Front End Pagination Problem

Postby Milbo » Thu Oct 14, 2010 11:41 am

Interesting, here is my solution that worked finally

So now it looks like that in the model:

Code: Select all

$this->setState('limit', $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $config->getValue('config.list_limit'), 'int'));
$this->setState('limitstart', JRequest::getVar('limitstart', 0, '', 'int'));

// In case limit has been changed, adjust limitstart accordingly
$this->setState('limitstart', ($this->getState('limit') != 0 ? (floor($this->getState('limitstart') / $this->getState('limit')) * $this->getState('limit')) : 0));


I use this lines in FE view.html.php:

Code: Select all

$pagination = $model->getPagination();
$this->assignRef('pagination',   $pagination);

and in the layout:

Code: Select all

<form name="adminForm" method="post">
<?php echo $this->pagination->getListFooter(); ?>
</form>


No changing of core files are needed, pagination works fine now.

naturalcrusader
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sun Feb 01, 2009 9:10 pm

Re: Front End Pagination Problem

Postby naturalcrusader » Thu Oct 14, 2010 1:33 pm

Milbo wrote:Interesting, here is my solution that worked finally

So now it looks like that in the model:

Code: Select all

$this->setState('limit', $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $config->getValue('config.list_limit'), 'int'));
$this->setState('limitstart', JRequest::getVar('limitstart', 0, '', 'int'));

// In case limit has been changed, adjust limitstart accordingly
$this->setState('limitstart', ($this->getState('limit') != 0 ? (floor($this->getState('limitstart') / $this->getState('limit')) * $this->getState('limit')) : 0));


I use this lines in FE view.html.php:

Code: Select all

$pagination = $model->getPagination();
$this->assignRef('pagination',   $pagination);

and in the layout:

Code: Select all

<form name="adminForm" method="post">
<?php echo $this->pagination->getListFooter(); ?>
</form>


No changing of core files are needed, pagination works fine now.


nice, great work!

thlas77
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Mon Oct 19, 2009 10:25 am

Re: Front End Pagination Problem

Postby thlas77 » Thu Oct 14, 2010 2:03 pm

I've just updated my model. It works fine except when i change the number of row to display in the listbox. It works randomly...sometimes, the new page has only a few lines, without the buttons to go to next pages (Even if there are other rows to display...) when I go back with the Firefox button, then it is correctly displayed ...)
Sometime, nothing is displayed...
It seems something is missing to be perfect !
Nobody has an idea about that ?
Thanks
Thierry

Milbo
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Fri Aug 08, 2008 7:33 am

Re: Front End Pagination Problem

Postby Milbo » Thu Oct 14, 2010 3:08 pm

Strange, for me it works, even with changing numbers, maybe you missed the second line (// In case limit has been changed, adjust limitstart accordingly ).

Of course it is a bit strange to set it twice. I am not quite sure if it is optimized, but at least it works for me. :-)

thlas77
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Mon Oct 19, 2009 10:25 am

Re: Front End Pagination Problem

Postby thlas77 » Thu Oct 14, 2010 7:33 pm

I have the 2nd line...and it doesn't work...Sometimes I have error message like this :
Trying to get property of non-object in C:\Program Files (x86)\EasyPHP5.3.0\www\totosicocm\components\com_content\views\frontpage\view.html.php on line 123


In my model I have :

Code: Select all

   function __construct()
   {
      parent::__construct();
      global $mainframe, $option;

                $this->setState('limit', $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'));
                $this->setState('limitstart', JRequest::getVar('limitstart', 0, '', 'int'));

                // In case limit has been changed, adjust limitstart accordingly
                $this->setState('limitstart', ($this->getState('limit') != 0 ? (floor($this->getState('limitstart') / $this->getState('limit')) * $this->getState('limit')) : 0));
        }

   /**
    * Method to get item data
         */
   function getData()
   {
      if (empty($this->_data))
      {
         $query = $this->_buildQuery();
         $this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
      }

      return $this->_data;
   }

   /**
    * Method to get the total number of items
    *
    */
   function getTotal()
   {
      if (empty($this->_total))
      {
         $query = $this->_buildQuery();
         $this->_total = $this->_getListCount($query);
      }

      return $this->_total;
   }

   /**
    * Method to get a pagination object
    */
   function getPagination()
   {
      if (empty($this->_pagination))
      {
         jimport('joomla.html.pagination');
         $this->_pagination = new JPagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
                }

      return $this->_pagination;
   }




In my Default :

Code: Select all

        <tfoot class="paginate">
            <tr>
                <td  colspan="8" >
                    <?php echo $this->pagination->getListFooter(); ?>
                </td>
            </tr>
        </tfoot>

In view.html :

Code: Select all

      $items   =& $this->get('data');
      $total      = & $this->get( 'Total');
      $pagination = & $this->get( 'Pagination' );


If someone can help me, I will be very pleased...
thanks
Thierry

dunio
Joomla! Apprentice
Joomla! Apprentice
Posts: 39
Joined: Wed Dec 14, 2011 3:59 pm

Re: Front End Pagination Problem

Postby dunio » Wed Dec 14, 2011 4:07 pm

I have this problem with the component JomSocial User List. What it does is categorizing JomSocial users by some criteria like profile type and profile fields, etc.
So, when one clicks on the userlist - a list of users appears according to some criteria... fine and very cool. When one goes to 2nd, 3rd page, etc. and one wants to go back to the start of category, clicking "beginning" or "1st page" does not work. It returns to 2nd page with start=5
example url when you click beginning or 1st page:
joomlafolder/userlistname?start=5

Anyone care to help to make it work with start=0 or remove the whole start variable idea for the 1st page? I am out of ideas.

deno028
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Apr 08, 2012 10:28 am

Re: Front End Pagination Problem

Postby deno028 » Mon Apr 09, 2012 3:41 am



Return to “Joomla! 1.5 Bug Reporting”

Who is online

Users browsing this forum: No registered users and 3 guests