Front End Pagination Problem
- tfuller
- Joomla! Enthusiast
- Posts: 218
- Joined: Tue Sep 20, 2005 11:30 pm
- Location: Oregon
- Contact:
Front End Pagination Problem
The pagination schema works on the back end fine but there is a problem on the front end.
The problem is going back to page one of the results.
On the backend the list correctly returns to LIMIT 0,0
But on the front end, using the exact same model as the backend, hitting Start or page 1 of results returns the present page. LIMIT also stays on the current page of results.
So the url, for instance, http://www.calvarychapelnewberg.org/ind ... itstart=20
Goes to page 2.
But then if you click on:
http://www.calvarychapelnewberg.org/ind ... Itemid=285
The front end list stays on page 2 of results and will not reset LIMIT.
I thought it was my coding error (and maybe it is) but there is a definite difference between how backend admin lists work and front end lists since I used the same model for back and front end with different results.
Is there someone who can enlighten as to code differences in pagination between front and back end?
Thanks!
tom
The problem is going back to page one of the results.
On the backend the list correctly returns to LIMIT 0,0
But on the front end, using the exact same model as the backend, hitting Start or page 1 of results returns the present page. LIMIT also stays on the current page of results.
So the url, for instance, http://www.calvarychapelnewberg.org/ind ... itstart=20
Goes to page 2.
But then if you click on:
http://www.calvarychapelnewberg.org/ind ... Itemid=285
The front end list stays on page 2 of results and will not reset LIMIT.
I thought it was my coding error (and maybe it is) but there is a definite difference between how backend admin lists work and front end lists since I used the same model for back and front end with different results.
Is there someone who can enlighten as to code differences in pagination between front and back end?
Thanks!
tom
Author of component Joomla Bible Study:
http://www.JoomlaBibleStudy.org
http://www.JoomlaBibleStudy.org
-
- Joomla! Apprentice
- Posts: 18
- Joined: Sun Jul 30, 2006 1:43 am
Re: Front End Pagination Problem
I have the same damn problem... goes to second page, but not back to the first.
I've observed something interesting: while in the backend doesn't apear any variables in the url's of the page buttons, they appear in the frontend. If you go to page one, and put your cursor above the link to the second page, the variable appear in the url "limitstart=5"... Strange isn't? i think i will write down some code to deal with the link creation of the pagination... I mean, is not that hard, and besides, what else can I do?
I've observed something interesting: while in the backend doesn't apear any variables in the url's of the page buttons, they appear in the frontend. If you go to page one, and put your cursor above the link to the second page, the variable appear in the url "limitstart=5"... Strange isn't? i think i will write down some code to deal with the link creation of the pagination... I mean, is not that hard, and besides, what else can I do?
- airton
- Joomla! Ace
- Posts: 1368
- Joined: Sun Nov 04, 2007 1:12 am
- Location: Brazil
- Contact:
Re: Front End Pagination Problem
Hi Tom,
Sorry for the long time without an answer to your question.
I can see from the links you posted that it's still an issue for you. If so, would you please use the Forum Post Assistant link in the pink box on top of this thread and post the results here? It will help a lot in diagnosing your problem.
khaotik, could you please do the same and, if possible, provide some example URLs for us to test it?
Thank you guys!
Regards,
Airton
Sorry for the long time without an answer to your question.
I can see from the links you posted that it's still an issue for you. If so, would you please use the Forum Post Assistant link in the pink box on top of this thread and post the results here? It will help a lot in diagnosing your problem.
khaotik, could you please do the same and, if possible, provide some example URLs for us to test it?
Thank you guys!
Regards,
Airton
Airton Torres
Joomla Bug Squad http://groups.google.com/group/joomlabugsquad
Community website - http://community.joomla.org
Unsolicited support PMs will be deleted and the user added to the foes list.
Joomla Bug Squad http://groups.google.com/group/joomlabugsquad
Community website - http://community.joomla.org
Unsolicited support PMs will be deleted and the user added to the foes list.
- tfuller
- Joomla! Enthusiast
- Posts: 218
- Joined: Tue Sep 20, 2005 11:30 pm
- Location: Oregon
- Contact:
Re: Front End Pagination Problem
Didn't know anything about the Forum Assistant. Pretty cool! Here is the post generation:
Problem Description:
Front page pagnination will not allow return to first page of results (no LIMITSTART) after navigating to any other page of results. Same model code works correctly on the admin backend.
Diagnostic Information
Joomla! Version: Joomla! 1.5.4 Production/Stable [ Naiki ] 6-July-2008 22:00 GMT
configuration.php: Writable (Mode: 775 ) | RG_EMULATION: N/A
Architecture/Platform: Linux infong 2.4 #1 SMP Wed Sep 26 00:19:50 CEST 2007 i686 GNU/Linux Linux infong 2.4 #1 SMP Wed Sep 26 00:19:50 CEST 2007 i686 GNU/Linux ( Linux infong 2.4 #1 SMP Wed Sep 26 00:19:50 CEST 2007 i686 GNU/Linux) | Web Server: Apache/1.3.34 Ben-SSL/1.55 ( www.joomlaoregon.org ) | PHP Version: 4.4.8
PHP Requirements: register_globals: Disabled | magic_quotes_gpc: Enabled | safe_mode: Disabled | MySQL Support: Yes | XML Support: Yes | zlib Support: Yes
mbstring Support (1.5): Yes | iconv Support (1.5): Yes | save.session_path: Writable | Max.Execution Time: 30 seconds | File Uploads: Enabled
MySQL Version: 5.0.51-log ( db1410.perfora.net via TCP/IP )
Extended Information:
SEF: Disabled (without ReWrite) | FTP Layer: Enabled | htaccess: Not Implemented
PHP/suExec: User and Web Server accounts are the same. (PHP/suExec probably installed)
PHP Environment: API: cgi | MySQLi: No | Max. Memory: 12M | Max. Upload Size: 20M | Max. Post Size: 8M | Max. Input Time: -1 | Zend Version: 1.3.0
Disabled Functions:
MySQL Client: 5.0.32 ( latin1 )
Problem Description:
Front page pagnination will not allow return to first page of results (no LIMITSTART) after navigating to any other page of results. Same model code works correctly on the admin backend.
Diagnostic Information
Joomla! Version: Joomla! 1.5.4 Production/Stable [ Naiki ] 6-July-2008 22:00 GMT
configuration.php: Writable (Mode: 775 ) | RG_EMULATION: N/A
Architecture/Platform: Linux infong 2.4 #1 SMP Wed Sep 26 00:19:50 CEST 2007 i686 GNU/Linux Linux infong 2.4 #1 SMP Wed Sep 26 00:19:50 CEST 2007 i686 GNU/Linux ( Linux infong 2.4 #1 SMP Wed Sep 26 00:19:50 CEST 2007 i686 GNU/Linux) | Web Server: Apache/1.3.34 Ben-SSL/1.55 ( www.joomlaoregon.org ) | PHP Version: 4.4.8
PHP Requirements: register_globals: Disabled | magic_quotes_gpc: Enabled | safe_mode: Disabled | MySQL Support: Yes | XML Support: Yes | zlib Support: Yes
mbstring Support (1.5): Yes | iconv Support (1.5): Yes | save.session_path: Writable | Max.Execution Time: 30 seconds | File Uploads: Enabled
MySQL Version: 5.0.51-log ( db1410.perfora.net via TCP/IP )
Extended Information:
SEF: Disabled (without ReWrite) | FTP Layer: Enabled | htaccess: Not Implemented
PHP/suExec: User and Web Server accounts are the same. (PHP/suExec probably installed)
PHP Environment: API: cgi | MySQLi: No | Max. Memory: 12M | Max. Upload Size: 20M | Max. Post Size: 8M | Max. Input Time: -1 | Zend Version: 1.3.0
Disabled Functions:
MySQL Client: 5.0.32 ( latin1 )
Author of component Joomla Bible Study:
http://www.JoomlaBibleStudy.org
http://www.JoomlaBibleStudy.org
- airton
- Joomla! Ace
- Posts: 1368
- Joined: Sun Nov 04, 2007 1:12 am
- Location: Brazil
- Contact:
Re: Front End Pagination Problem
Hi Tom,
Thanks for posting those results. It will help a lot.
I have a few more questions though.
- Are there actually articles that are not being shown because they belong to page 1 or is it just the indication of page 2 of 26 that is wrong and should be 1 of 26 or 1 of 25?
- What kind of view has the problem? Article Layout, Category Blog, Category List, etc, or all of them?
Thanks for raising this issue.
Regards,
Airton
Thanks for posting those results. It will help a lot.
I have a few more questions though.
- Are there actually articles that are not being shown because they belong to page 1 or is it just the indication of page 2 of 26 that is wrong and should be 1 of 26 or 1 of 25?
- What kind of view has the problem? Article Layout, Category Blog, Category List, etc, or all of them?
Thanks for raising this issue.
Regards,
Airton
Airton Torres
Joomla Bug Squad http://groups.google.com/group/joomlabugsquad
Community website - http://community.joomla.org
Unsolicited support PMs will be deleted and the user added to the foes list.
Joomla Bug Squad http://groups.google.com/group/joomlabugsquad
Community website - http://community.joomla.org
Unsolicited support PMs will be deleted and the user added to the foes list.
- tfuller
- Joomla! Enthusiast
- Posts: 218
- Joined: Tue Sep 20, 2005 11:30 pm
- Location: Oregon
- Contact:
Re: Front End Pagination Problem
1. Yes - there are actually articles not being shown. When you first go to the listing it is sorted normally by date descending (though you can change that). If you go to page 2 then back to page one the results from page 2 "stick" and you can no longer see the results from page 1
2. As for the layout - its a third party component but it's a listing of links to articles. It's in a component/view/studieslist/tmpl/default.php
This is my pagination function in the model:
2. As for the layout - its a third party component but it's a listing of links to articles. It's in a component/view/studieslist/tmpl/default.php
This is my pagination function in the model:
Code: Select all
function getPagination()
{
// Lets load the content if it doesn't already exist
if (empty($this->_pagination))
{
jimport('joomla.html.pagination');
$total = $this->getTotal();
$limitstart = $this->getState('limitstart');
$limit = $this->getState('limit');
$this->_pagination = new JPagination( $total, $limitstart, $limit );
}
return $this->_pagination;
Author of component Joomla Bible Study:
http://www.JoomlaBibleStudy.org
http://www.JoomlaBibleStudy.org
- airton
- Joomla! Ace
- Posts: 1368
- Joined: Sun Nov 04, 2007 1:12 am
- Location: Brazil
- Contact:
Re: Front End Pagination Problem
So, this isn't a Joomla! issue. The problem resides in your pagination function, as can be noted in other parts of your site where the component is not used and the pagination works as expected.tfuller wrote:1...
2. As for the layout - its a third party component but it's a listing of links to articles. It's in a component/view/studieslist/tmpl/default.php
...
I suggest you look at how pagination is done in other core files and if replacing it solves your problem. maybe the code you based your function has subsequently been fixed.
Hope this helps.
Best regards,
Airton
Airton Torres
Joomla Bug Squad http://groups.google.com/group/joomlabugsquad
Community website - http://community.joomla.org
Unsolicited support PMs will be deleted and the user added to the foes list.
Joomla Bug Squad http://groups.google.com/group/joomlabugsquad
Community website - http://community.joomla.org
Unsolicited support PMs will be deleted and the user added to the foes list.
- tfuller
- Joomla! Enthusiast
- Posts: 218
- Joined: Tue Sep 20, 2005 11:30 pm
- Location: Oregon
- Contact:
Re: Front End Pagination Problem
Thanks, Airton - I based my code on other core components so I expected it to work correctly but it is not a Joomla core issue. Thanks for your attention!
Tom
Tom
Author of component Joomla Bible Study:
http://www.JoomlaBibleStudy.org
http://www.JoomlaBibleStudy.org
- airton
- Joomla! Ace
- Posts: 1368
- Joined: Sun Nov 04, 2007 1:12 am
- Location: Brazil
- Contact:
Re: [NOT A JOOMLA! ISSUE] Front End Pagination Problem
Sorry if i couldn't be of much help here. I'm not a very skilled PHP coder and I'm still learning J!1.5 framework, but as a volunteer to help Joomla! Bug Squad I had to step into this issue.
Hopefully you'll find a solution reviewing your code or get some more skilled person to help you out, after all this is what this community is all about.
I wish you the best of luck!
Regards,
Airton.
Hopefully you'll find a solution reviewing your code or get some more skilled person to help you out, after all this is what this community is all about.
I wish you the best of luck!
Regards,
Airton.
Airton Torres
Joomla Bug Squad http://groups.google.com/group/joomlabugsquad
Community website - http://community.joomla.org
Unsolicited support PMs will be deleted and the user added to the foes list.
Joomla Bug Squad http://groups.google.com/group/joomlabugsquad
Community website - http://community.joomla.org
Unsolicited support PMs will be deleted and the user added to the foes list.
- tfuller
- Joomla! Enthusiast
- Posts: 218
- Joined: Tue Sep 20, 2005 11:30 pm
- Location: Oregon
- Contact:
Re: Front End Pagination Problem
No problem - this issue had kind of fallen off my radar but now I'm reviewing the core code and noticing some different ways of doing it. I took my code from James Kennard's great book Mastering Joomla! 1.5 but I notice now that the com_content uses different code in their model and in their views to accomplish pagination on the front end so I'll work at implementing that and see if it works!
Cheers.
Tom
Cheers.
Tom
Author of component Joomla Bible Study:
http://www.JoomlaBibleStudy.org
http://www.JoomlaBibleStudy.org
- tfuller
- Joomla! Enthusiast
- Posts: 218
- Joined: Tue Sep 20, 2005 11:30 pm
- Location: Oregon
- Contact:
Re: Front End Pagination Problem
Just in case someone else has problems with a third party component not paginating correctly on the front end - here is how I solved the problem - using the model from weblinks in 1.5.3
This is in the list display model:
Then in the list display template default.php:
This is in the list display model:
Code: Select all
function __construct()
{
parent::__construct();
global $mainframe, $option;
$config = JFactory::getConfig();
// Get the pagination request variables
$this->setState('limit', $mainframe->getUserStateFromRequest('com_biblestudy.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));
}
function getData()
{
// Lets load the data if it doesn't already exist
if (empty( $this->_data ))
{
$query = $this->_buildQuery();
$this->_data = $this->_getList( $query, $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_data;
}
function getPagination()
{
// Lets load the content if it doesn't already exist
if (empty($this->_pagination))
{
jimport('joomla.html.pagination');
$this->_pagination = new JPagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_pagination;
}
Code: Select all
echo ' '.JText::_('Display Num').' ';
echo $this->pagination->getLimitBox();
echo $this->pagination->getPagesLinks();
echo $this->pagination->getPagesCounter();
Author of component Joomla Bible Study:
http://www.JoomlaBibleStudy.org
http://www.JoomlaBibleStudy.org
-
- Joomla! Apprentice
- Posts: 7
- Joined: Thu Apr 19, 2007 1:29 pm
Re: Front End Pagination Problem
I was getting the same error when trying to go back to page one. I pulled my example out of a packt publisher "mastering joomla" book. It seems the $limitstart in the construct was causing my issue.
I changed the following:
To what you have:
And it works like magic. Okay, it's just sensible coding.
Apparently it looks like the limitstart in the first part will just keep getting set to the last request, which I guess doesn't change when you click on page 2 or next.
However, the limitstart does get pass in the JRequest so that is where it is pulling it from on subsequent paging through lists. Thank goodness I found this thread.
Thanks!
I changed the following:
Code: Select all
$limitstart = $mainframe->getUserStateFromRequest($option.'limitstart', 'limitstart', 0, 'int');
$this->setState('limitstart', $limitstart);
Code: Select all
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');
$this->setState('limitstart', $limitstart);
Apparently it looks like the limitstart in the first part will just keep getting set to the last request, which I guess doesn't change when you click on page 2 or next.
However, the limitstart does get pass in the JRequest so that is where it is pulling it from on subsequent paging through lists. Thank goodness I found this thread.
Thanks!
- tfuller
- Joomla! Enthusiast
- Posts: 218
- Joined: Tue Sep 20, 2005 11:30 pm
- Location: Oregon
- Contact:
Re: Front End Pagination Problem
That's great! It took me forever to find a solution and I thought I was going mad.
Author of component Joomla Bible Study:
http://www.JoomlaBibleStudy.org
http://www.JoomlaBibleStudy.org
-
- Joomla! Apprentice
- Posts: 40
- Joined: Tue Aug 01, 2006 3:48 am
Re: Front End Pagination Problem
Thank you! I had this exact same problem with from-scratch code that made the same mistake. I was persisting limitstart across the request, so the code in pagination that removed it from the arguments on the URL simply meant that the persisted value stuck around.
This thread was my lightbulb moment :-)
This thread was my lightbulb moment :-)
-
- Joomla! Apprentice
- Posts: 30
- Joined: Mon Jan 12, 2009 10:30 am
Re: Front End Pagination Problem
Just wanted to say thanks for this blog. I also thought I was going crazy.
-
- Joomla! Apprentice
- Posts: 26
- Joined: Wed Feb 04, 2009 11:56 am
Re: Front End Pagination Problem
I had the same issue and got it solved with the modification of $limitstart in the model constructor posted here. Before finding this post, I came up to the solution thanks to this book: "Learning Joomla! 1.5 Extension Development". However, the non working code is the one you find in "Mastering Joomla 1.5 " and also here: http://docs.joomla.org/Using_JPaginatio ... _component. Perhaps a more experimented Joomla developer could help us understand .
Thanks.
Thanks.
-
- Joomla! Intern
- Posts: 89
- Joined: Thu Apr 30, 2009 6:21 pm
- Contact:
Re: Front End Pagination Problem
I was using the same book to build my Pagination and came across the issue when I would have two different views using pagination. Say I clicked on page 4 of one view and went back to my other view which only had 2 pages of data. No data would display because it was stuck on page 4 which doesn't exist.
Changing to this fixed my issue.
Changing to this fixed my issue.
Code: Select all
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');
Site: http://billengle.info
-
- Joomla! Intern
- Posts: 69
- Joined: Wed Sep 17, 2008 4:37 am
Re: Front End Pagination Problem
Thanks a lot for the code.. I had the exact same problem.. i replaced the code and it works great.. was hitting my head for a week on this
SEO-Mind http://www.seo-mind.com
World's Best Guitarists http://www.worldguitarists.com
World's Best Guitarists http://www.worldguitarists.com
-
- Joomla! Enthusiast
- Posts: 148
- Joined: Sat Jul 18, 2009 11:19 am
Re: Front End Pagination Problem
I have the same problem and i want to know which files did u edit???
- tfuller
- Joomla! Enthusiast
- Posts: 218
- Joined: Tue Sep 20, 2005 11:30 pm
- Location: Oregon
- Contact:
Re: Front End Pagination Problem
This happens in your model files.
Author of component Joomla Bible Study:
http://www.JoomlaBibleStudy.org
http://www.JoomlaBibleStudy.org
-
- Joomla! Apprentice
- Posts: 18
- Joined: Sun Feb 01, 2009 9:10 pm
Re: Front End Pagination Problem
The issue i am having is that the front end is using links instead of submits. On the backend it will 'submit' using javascript, on the front end it is using a link to go back to index.php?limitstart=## .. this is a problem as I cannot keep my component, view, and task set.
So is this a bug? Is this something I have to change the source code for? Is this something I will have to try and just recreate in the module instead of using the 'built-in' pagination?
thanks!
or do they expect you to use sessions??
in playing around with it - i noticed something else -->
if I don't change the number of listed items the above holds true. but, when I changed the view to list 30 items, it fixed all of the links to include the task, controller, view...?
I thought of trying it with different numbers of items shown - this time all did not work (including the 30 view)
So is this a bug? Is this something I have to change the source code for? Is this something I will have to try and just recreate in the module instead of using the 'built-in' pagination?
thanks!
or do they expect you to use sessions??
in playing around with it - i noticed something else -->
if I don't change the number of listed items the above holds true. but, when I changed the view to list 30 items, it fixed all of the links to include the task, controller, view...?
I thought of trying it with different numbers of items shown - this time all did not work (including the 30 view)
- tfuller
- Joomla! Enthusiast
- Posts: 218
- Joined: Tue Sep 20, 2005 11:30 pm
- Location: Oregon
- Contact:
Re: Front End Pagination Problem
If you are using an href link you will need to set at least the component and view and limitstart. Your model should grab limitstart from the request variable.
index.php?option=com_yourcomponent&view=yourview&limitstart=10
There is no "built in pagination" other than the presentation in the footer. Your model pretty much has to handle it, so it needs to get the component/view/limit variables from somewhere. You can set them by JRequest::setVar('myvariable', 'int'); etc within your view, or you can just include them in the href link.
index.php?option=com_yourcomponent&view=yourview&limitstart=10
There is no "built in pagination" other than the presentation in the footer. Your model pretty much has to handle it, so it needs to get the component/view/limit variables from somewhere. You can set them by JRequest::setVar('myvariable', 'int'); etc within your view, or you can just include them in the href link.
Author of component Joomla Bible Study:
http://www.JoomlaBibleStudy.org
http://www.JoomlaBibleStudy.org
-
- Joomla! Apprentice
- Posts: 18
- Joined: Sun Feb 01, 2009 9:10 pm
Re: Front End Pagination Problem
I am using the built in pagination (JPagination) - I use the following on both the back end and the front with different results
<tfoot>
<tr>
<td colspan="12" align='center' ><?php echo $this->pagination->getListFooter(); ?></td>
</tr>
</tfoot>
on the back it is as normal (with javascript submitting the links):
<a href="#" title="1" onclick="javascript: document.adminForm.limitstart.value=0; submitform();return false;">1</a>
however on the front:
<a title="2" href="[domain]/index.php?limitstart=20" class="pagenav">2</a>
in the view (in both front/back):
function display($tpl = null)
{
$records = & $this->get( 'Data');
$pagination =& $this->get('Pagination');
$this->assignRef('records', $records);
$this->assignRef('pagination', $pagination);
parent::display($tpl);
}
in the model (both again)
var $_total = null;
var $_pagination = null;
function __construct()
{
parent::__construct();
global $mainframe, $option;
// Get pagination request variables
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');
// In case limit has been changed, adjust it
$limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
function getTotal()
{
// Load the content if it doesn't already exist
if (empty($this->_total)) {
$query = $this->_buildQuery();
$this->_total = $this->_getListCount($query);
}
return $this->_total;
}
function getPagination()
{
// Load the content if it doesn't already exist
if (empty($this->_pagination)) {
jimport('joomla.html.pagination');
$this->_pagination = new JPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_pagination;
}
// same exact code in both the front and back with different results
the problem is I WANT it to post - but it is giving me HREF links instead of the submits. so do I need to change the JPagination class or is there someother way to do it?
thanks for your help!
<tfoot>
<tr>
<td colspan="12" align='center' ><?php echo $this->pagination->getListFooter(); ?></td>
</tr>
</tfoot>
on the back it is as normal (with javascript submitting the links):
<a href="#" title="1" onclick="javascript: document.adminForm.limitstart.value=0; submitform();return false;">1</a>
however on the front:
<a title="2" href="[domain]/index.php?limitstart=20" class="pagenav">2</a>
in the view (in both front/back):
function display($tpl = null)
{
$records = & $this->get( 'Data');
$pagination =& $this->get('Pagination');
$this->assignRef('records', $records);
$this->assignRef('pagination', $pagination);
parent::display($tpl);
}
in the model (both again)
var $_total = null;
var $_pagination = null;
function __construct()
{
parent::__construct();
global $mainframe, $option;
// Get pagination request variables
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');
// In case limit has been changed, adjust it
$limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
function getTotal()
{
// Load the content if it doesn't already exist
if (empty($this->_total)) {
$query = $this->_buildQuery();
$this->_total = $this->_getListCount($query);
}
return $this->_total;
}
function getPagination()
{
// Load the content if it doesn't already exist
if (empty($this->_pagination)) {
jimport('joomla.html.pagination');
$this->_pagination = new JPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_pagination;
}
// same exact code in both the front and back with different results
the problem is I WANT it to post - but it is giving me HREF links instead of the submits. so do I need to change the JPagination class or is there someother way to do it?
thanks for your help!
- tfuller
- Joomla! Enthusiast
- Posts: 218
- Joined: Tue Sep 20, 2005 11:30 pm
- Location: Oregon
- Contact:
Re: Front End Pagination Problem
I've never gotten a good explanation as to why the JPagination works differently on the front end.
As for me, I added this code to my model:
at the bottom of the construct function. It seemed to do the trick.
As for me, I added this code to my model:
Code: Select all
// In case we are on more than page 1 of results and the total changes in one of the drop downs to a selection that has fewer in its total, we change limitstart
if ($this->getTotal() < $this->getState('limitstart')) {$this->setState('limitstart', 0,'','int');}
Author of component Joomla Bible Study:
http://www.JoomlaBibleStudy.org
http://www.JoomlaBibleStudy.org
-
- Joomla! Apprentice
- Posts: 18
- Joined: Sun Feb 01, 2009 9:10 pm
Re: Front End Pagination Problem
naturalcrusader wrote: on the back it is as normal (with javascript submitting the links):
<a href="#" title="1" onclick="javascript: document.adminForm.limitstart.value=0; submitform();return false;">1</a>
however on the front:
<a title="2" href="[domain]/index.php?limitstart=20" class="pagenav">2</a>
Okay - I decided just to look at the source code:
libraries/joomla/html/pagination.php
line 439 starts the function _item_active.
Code: Select all
function _item_active(&$item)
{
global $mainframe;
if ($mainframe->isAdmin())
{
if($item->base>0)
return "<a title=\"".$item->text."\" onclick=\"javascript: document.adminForm.limitstart.value=".$item->base."; submitform();return false;\">".$item->text."</a>";
else
return "<a title=\"".$item->text."\" onclick=\"javascript: document.adminForm.limitstart.value=0; submitform();return false;\">".$item->text."</a>";
} else {
return "<a title=\"".$item->text."\" href=\"".$item->link."\" class=\"pagenav\">".$item->text."</a>";
}
}
so the new function looks like:
Code: Select all
function _item_active(&$item)
{
global $mainframe;
if ($mainframe->isAdmin())
{
if($item->base>0)
return "<a title=\"".$item->text."\" onclick=\"javascript: document.adminForm.limitstart.value=".$item->base."; submitform();return false;\">".$item->text."</a>";
else
return "<a title=\"".$item->text."\" onclick=\"javascript: document.adminForm.limitstart.value=0; submitform();return false;\">".$item->text."</a>";
} else {
if($item->base == "")
$item->base = 0;
return "\n<a title=\"".$item->text."\" onclick=\"javascript: document.adminForm.limitstart.value=".$item->base."; document.adminForm.submit(); \" >".$item->text."</a>";
}
}
NaturalCrusader
PS - this assumes your form name is 'adminForm'
Last edited by naturalcrusader on Wed Aug 26, 2009 11:38 pm, edited 1 time in total.
- tfuller
- Joomla! Enthusiast
- Posts: 218
- Joined: Tue Sep 20, 2005 11:30 pm
- Location: Oregon
- Contact:
Re: Front End Pagination Problem
you should submit this as a bug fix in that forum. Great job!
Author of component Joomla Bible Study:
http://www.JoomlaBibleStudy.org
http://www.JoomlaBibleStudy.org
-
- Joomla! Apprentice
- Posts: 40
- Joined: Fri May 16, 2008 9:55 am
- Contact:
Re: Front End Pagination Problem
Last edited by saisimha on Sun Aug 30, 2009 6:01 pm, edited 1 time in total.
-
- Joomla! Enthusiast
- Posts: 102
- Joined: Mon Mar 09, 2009 6:36 pm
Re: Front End Pagination Problem
Why
instead of
?
Code: Select all
echo ' '.JText::_('Display Num').' ';
echo $this->pagination->getLimitBox();
echo $this->pagination->getPagesLinks();
echo $this->pagination->getPagesCounter();
Code: Select all
echo $this->page->getListFooter();
- abstraktron
- Joomla! Explorer
- Posts: 299
- Joined: Sat Apr 15, 2006 6:43 am
- Location: Los Angeles, CA, USA
- Contact:
Re: Front End Pagination Problem
getListFooter() should work the same too. Thanks for this thread, very helpful.
-
- Joomla! Apprentice
- Posts: 25
- Joined: Wed Jan 13, 2010 6:33 am
Re: Front End Pagination Problem
works great saved my life I mean my time