paging problem

7 posts by 2 authors in: Forums > CMS Builder
Last Post: January 16, 2009   (RSS)

I have a strange paging problem. I have a viewer on a newsDetail page that displays the news item then the comments that are linked to news items by the num field of the news table. There are actually four viewers on this page (the other two are not important).

The problem I am having is with paging of the comments.

Example: if I page to the second comments page the page displays the news item and page 2 of the comments just fine. However, if I page to page 3 or back to page 1, even though the url is correct the wrong news item page displays?

I am using the getNumberFromEndOfUrl() function to grab the num value from the news item and then using it in the where clause of the comments viewer. The strange part of this is that the url on the paging link and in the address bar are correct but it goes to the wrong news item.

Any ideas as to why this happens?

Re: [Dave] paging problem

Code is only running on my dev server so I can't show you a link. However, your suggestion points out the problem which is related to how the getNumberFromEndOfUrl() function works. It does exactly what it says, gets the number from the end of the url which as you suggested is the value after page=3. The solution to the problem was a simple change to the getNumberFromEndOfUrl() so that it first removes any data from the url after the =& that appears on a link. After making that change it works just fine and as expected. If doing this won't cause any problems then maybe the function could be modified for future versions?

Re: [jsantari] paging problem

By Dave - January 14, 2009

Can you post your code changes so I can see?

Generally it works well when you're just passing the record number, but if you have multiple values you need to pass them manually and load the values or at the last make sure the record number is on the end. eg: ?page=2&num=1
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] paging problem

In getNumberFromEndOfUrl() function I added these two lines right before the if (preg_match...) statement:

$url = explode('=&',$urlData);
$urlData = $url[0];

It makes $urlData always contain just the url we want to strip the num off of.

Jim

Re: [jsantari] paging problem

By Dave - January 15, 2009

Hi Jim,

Interesting. We won't be able to add that to viewer_functions.php because some people rely on the currently functionality of getting the number from the end of the url (instead of the beginning of the url).

To make your version upgrade proof I'd suggest creating a copy of the function called getNumberFromUrl() or something else and calling that one.

Hope that helps. Let me know if you need anything else.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] paging problem

Hi Dave,

I have created a second function in my own lib file as you suggested and it works fine.

Thanks,
Jim