L8.6 Next and Previous

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

L8.6 Next and Previous

Patrick Larkin-2
Sorry for the rudimentary question but I've been unable for years to do a found set of records with a Next button and Previous button.  I've tried numerous examples and either am missing something fundamental or haven't seen a good explanation of how to do it.  I know there were dedicated tags for this but am I correct that they are not used any longer?  Usually, this hasn't been an issue because the records returned in my applications are generally not that high.  

If someone can point me to a good explanation or tutorial on how to do it, I'd appreciate it.  

Patrick Larkin
Information Systems
Bethlehem Area School District
https://www.beth.k12.pa.us




#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 Next and Previous

Jolle Carlestam-2
I suggest you take a look at Knop grid. It gives you navigation to next, previous, last, first, skip X pages, quick search etc.

HDB
Jolle

Sent from a thin, flat, touchy device from an undetermined place in space.

> 14 mar 2014 kl. 04:59 skrev Patrick Larkin <[hidden email]>:
>
> Sorry for the rudimentary question but I've been unable for years to do a found set of records with a Next button and Previous button.  I've tried numerous examples and either am missing something fundamental or haven't seen a good explanation of how to do it.  I know there were dedicated tags for this but am I correct that they are not used any longer?  Usually, this hasn't been an issue because the records returned in my applications are generally not that high.  
>
> If someone can point me to a good explanation or tutorial on how to do it, I'd appreciate it.  
>
> Patrick Larkin
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 Next and Previous

French, Shelane
This is the tag I have for paginating the results, which is a slight
modification to a tag Jason Huck wrote. It contains specifics to how I
want my links to show:

[define_tag(
                'pagination',
                -namespace='results_',
                -required='base_link', -type='string',
                -opt='found', -type='integer',
                -opt='shown', -type='integer',
                -opt='skipped', -type='integer',
                -opt='range', -type='integer',
                -priority='replace',
                -description='Generates links for found set navigation.'
        );
                !local_defined('id') ? local('id' = lasso_uniqueid);
       
                local(
                        'found_count' = (local_defined('found') ? #found | found_count),
                        'shown_count' = (local_defined('shown') ? #shown | maxrecords_value),
                        'shown_page' = integer,
                        'skip_counts' = array,
                        'skip' = (local_defined('skipped') ? #skipped | skiprecords_value),
                        'counter' = 0,
                        'radius' = 2,
                        'display' = string,
                        'prev' = string,
                        'next' = string,
                        'first' = string,
                        'last' = string,
                        'lower' = integer,
                        'upper' = integer,
                        'out' = string
                );

                // no navigation is needed if #found_count < #shown_count
                if(#found_count > #shown_count);
                        // range defaults to 5
                        !local_defined('range') ? local('range' = 5);
                        #radius = #range / 2;
                                               
                        // calculate number of pages
                        local('pages' = #found_count / #shown_count);
                        #found_count % #shown_count > 0 ? #pages += 1;
                       
                        // calculate skip count for each page
                        loop(#pages);
                                #skip_counts->insert(#counter);
                                #counter += #shown_count;
                        /loop;
                       
                        // find the current page
                        #shown_page = (#found_count > 0 ?
#skip_counts->findposition(#skip)->get(1) | 0);
       
                        // determine range of pages to show
                        #lower = #skip - (#shown_count * #radius);
                        #upper = #skip + (#shown_count * #radius);
               
                        // find previous/next, first/last links
                        if(#shown_page > 1);
                                #prev = '<li><a href="' #base_link '&skip=' (#skip - #shown_count) '"
rel="nofollow">&lt;</a></li>';
                                #first = '<li><a href="' #base_link '&skip=0"
rel="nofollow">&lt;&lt;</a></li>';
                        /if;
                       
                        if(#shown_page < #skip_counts->size);
                                #next = '<li><a href="' #base_link '&skip=' (#skip + #shown_count) '"
rel="nofollow">&gt;</a></li>';
                                #last = '<li><a href="' #base_link '&skip=' #skip_counts->last '"
rel="nofollow">&gt;&gt;</a></li>';
                        /if;
                               
                        // generate individual page nav links
                        iterate(#skip_counts, local('this'));
                                if(#this >= #lower && #this <= #upper);
                                        #display += '<li' (#shown_page == loop_count ? ' class="active"') '>';
                                        #display += '<a href="' #base_link '&skip=' #this '">' loop_count
'</a></li>';
                                /if;
                        /iterate;
                       
                        #out = '<div class="pagination"><ul>' + #first + #prev + (#radius > 0 ?
#display) + #next + #last + '</div>\n';
                       
                        return(@#out);
                /if;
        /define_tag;
        ]



On 3/13/14, 2:13 PM, "Jolle Carlestam" <[hidden email]> wrote:

I suggest you take a look at Knop grid. It gives you navigation to next,
previous, last, first, skip X pages, quick search etc.

HDB
Jolle

Sent from a thin, flat, touchy device from an undetermined place in space.

> 14 mar 2014 kl. 04:59 skrev Patrick Larkin <[hidden email]>:
>
> Sorry for the rudimentary question but I've been unable for years to do
>a found set of records with a Next button and Previous button.  I've
>tried numerous examples and either am missing something fundamental or
>haven't seen a good explanation of how to do it.  I know there were
>dedicated tags for this but am I correct that they are not used any
>longer?  Usually, this hasn't been an issue because the records returned
>in my applications are generally not that high.
>
> If someone can point me to a good explanation or tutorial on how to do
>it, I'd appreciate it.
>
> Patrick Larkin
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 Next and Previous

stevepiercy
In reply to this post by Jolle Carlestam-2
Knop Project Link:
https://github.com/knop-project/knop

Real example:
http://www.norcalreferees.com/suspensions/

Alternatively as Shelane mentioned, these tags by Jason Huck are
useful for this purpose.
http://www.lassosoft.com/tagswap/detail/results_navigation
http://www.lassosoft.com/tagswap/detail/results_table
http://www.lassosoft.com/tagswap/detail/results_status
http://www.lassosoft.com/tagswap/detail/client_params/

--steve


On 3/14/14 at 7:13 AM, [hidden email] (Jolle Carlestam) pronounced:

>I suggest you take a look at Knop grid. It gives you navigation
>to next, previous, last, first, skip X pages, quick search etc.
>
>HDB
>Jolle
>
>Sent from a thin, flat, touchy device from an undetermined place in space.
>
>>14 mar 2014 kl. 04:59 skrev Patrick Larkin <[hidden email]>:
>>
>>Sorry for the rudimentary question but I've been unable for years to do a found set of records with
>a Next button and Previous button.  I've tried numerous
>examples and either am missing something fundamental or haven't
>seen a good explanation of how to do it.  I know there were
>dedicated tags for this but am I correct that they are not used
>any longer?  Usually, this hasn't been an issue because the
>records returned in my applications are generally not that high.
>>
>>If someone can point me to a good explanation or tutorial on
>>how to do it, I'd appreciate it.
>>Patrick Larkin
>#############################################################
>This message is sent to you because you are subscribed to
>the mailing list Lasso [hidden email]
>Official list archives available at http://www.lassotalk.com
>To unsubscribe, E-mail to: <[hidden email]>
>Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 Next and Previous

Patrick Larkin-2
In reply to this post by French, Shelane
Thanks.  I've tried those tags in the past and couldn't get them to work.  I think I just don't understand the code or the logic enough.

Sent from my iPad

> On Mar 13, 2014, at 5:17 PM, "French, Shelane" <[hidden email]> wrote:
>
> This is the tag I have for paginating the results, which is a slight
> modification to a tag Jason Huck wrote. It contains specifics to how I
> want my links to show:
>
> [define_tag(
>        'pagination',
>        -namespace='results_',
>        -required='base_link', -type='string',
>        -opt='found', -type='integer',
>        -opt='shown', -type='integer',
>        -opt='skipped', -type='integer',
>        -opt='range', -type='integer',    
>        -priority='replace',
>        -description='Generates links for found set navigation.'
>    );
>        !local_defined('id') ? local('id' = lasso_uniqueid);
>    
>        local(
>            'found_count' = (local_defined('found') ? #found | found_count),
>            'shown_count' = (local_defined('shown') ? #shown | maxrecords_value),
>            'shown_page' = integer,
>            'skip_counts' = array,
>            'skip' = (local_defined('skipped') ? #skipped | skiprecords_value),
>            'counter' = 0,
>            'radius' = 2,
>            'display' = string,
>            'prev' = string,
>            'next' = string,
>            'first' = string,
>            'last' = string,
>            'lower' = integer,
>            'upper' = integer,
>            'out' = string
>        );
>
>        // no navigation is needed if #found_count < #shown_count
>        if(#found_count > #shown_count);
>            // range defaults to 5
>            !local_defined('range') ? local('range' = 5);        
>            #radius = #range / 2;
>                        
>            // calculate number of pages
>            local('pages' = #found_count / #shown_count);    
>            #found_count % #shown_count > 0 ? #pages += 1;
>            
>            // calculate skip count for each page
>            loop(#pages);
>                #skip_counts->insert(#counter);
>                #counter += #shown_count;
>            /loop;
>            
>            // find the current page
>            #shown_page = (#found_count > 0 ?
> #skip_counts->findposition(#skip)->get(1) | 0);
>    
>            // determine range of pages to show
>            #lower = #skip - (#shown_count * #radius);
>            #upper = #skip + (#shown_count * #radius);
>        
>            // find previous/next, first/last links
>            if(#shown_page > 1);        
>                #prev = '<li><a href="' #base_link '&skip=' (#skip - #shown_count) '"
> rel="nofollow">&lt;</a></li>';
>                #first = '<li><a href="' #base_link '&skip=0"
> rel="nofollow">&lt;&lt;</a></li>';
>            /if;
>            
>            if(#shown_page < #skip_counts->size);
>                #next = '<li><a href="' #base_link '&skip=' (#skip + #shown_count) '"
> rel="nofollow">&gt;</a></li>';
>                #last = '<li><a href="' #base_link '&skip=' #skip_counts->last '"
> rel="nofollow">&gt;&gt;</a></li>';
>            /if;
>                
>            // generate individual page nav links
>            iterate(#skip_counts, local('this'));
>                if(#this >= #lower && #this <= #upper);
>                    #display += '<li' (#shown_page == loop_count ? ' class="active"') '>';
>                    #display += '<a href="' #base_link '&skip=' #this '">' loop_count
> '</a></li>';
>                /if;
>            /iterate;
>            
>            #out = '<div class="pagination"><ul>' + #first + #prev + (#radius > 0 ?
> #display) + #next + #last + '</div>\n';
>            
>            return(@#out);
>        /if;
>    /define_tag;
>    ]
>
>
>
> On 3/13/14, 2:13 PM, "Jolle Carlestam" <[hidden email]> wrote:
>
> I suggest you take a look at Knop grid. It gives you navigation to next,
> previous, last, first, skip X pages, quick search etc.
>
> HDB
> Jolle
>
> Sent from a thin, flat, touchy device from an undetermined place in space.
>
>> 14 mar 2014 kl. 04:59 skrev Patrick Larkin <[hidden email]>:
>>
>> Sorry for the rudimentary question but I've been unable for years to do
>> a found set of records with a Next button and Previous button.  I've
>> tried numerous examples and either am missing something fundamental or
>> haven't seen a good explanation of how to do it.  I know there were
>> dedicated tags for this but am I correct that they are not used any
>> longer?  Usually, this hasn't been an issue because the records returned
>> in my applications are generally not that high.
>>
>> If someone can point me to a good explanation or tutorial on how to do
>> it, I'd appreciate it.
>>
>> Patrick Larkin
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 Next and Previous

Tami Williams
I think you need to see the page that = #base_link (that's the page that actually does the search with the skipRecords, etc.)


On Mar 13, 2014, at 8:35 PM, Patrick Larkin <[hidden email]> wrote:

> Thanks.  I've tried those tags in the past and couldn't get them to work.  I think I just don't understand the code or the logic enough.
>
> Sent from my iPad
>
>> On Mar 13, 2014, at 5:17 PM, "French, Shelane" <[hidden email]> wrote:
>>
>> This is the tag I have for paginating the results, which is a slight
>> modification to a tag Jason Huck wrote. It contains specifics to how I
>> want my links to show:
>>
>> [define_tag(
>>       'pagination',
>>       -namespace='results_',
>>       -required='base_link', -type='string',
>>       -opt='found', -type='integer',
>>       -opt='shown', -type='integer',
>>       -opt='skipped', -type='integer',
>>       -opt='range', -type='integer',    
>>       -priority='replace',
>>       -description='Generates links for found set navigation.'
>>   );
>>       !local_defined('id') ? local('id' = lasso_uniqueid);
>>
>>       local(
>>           'found_count' = (local_defined('found') ? #found | found_count),
>>           'shown_count' = (local_defined('shown') ? #shown | maxrecords_value),
>>           'shown_page' = integer,
>>           'skip_counts' = array,
>>           'skip' = (local_defined('skipped') ? #skipped | skiprecords_value),
>>           'counter' = 0,
>>           'radius' = 2,
>>           'display' = string,
>>           'prev' = string,
>>           'next' = string,
>>           'first' = string,
>>           'last' = string,
>>           'lower' = integer,
>>           'upper' = integer,
>>           'out' = string
>>       );
>>
>>       // no navigation is needed if #found_count < #shown_count
>>       if(#found_count > #shown_count);
>>           // range defaults to 5
>>           !local_defined('range') ? local('range' = 5);        
>>           #radius = #range / 2;
>>
>>           // calculate number of pages
>>           local('pages' = #found_count / #shown_count);    
>>           #found_count % #shown_count > 0 ? #pages += 1;
>>
>>           // calculate skip count for each page
>>           loop(#pages);
>>               #skip_counts->insert(#counter);
>>               #counter += #shown_count;
>>           /loop;
>>
>>           // find the current page
>>           #shown_page = (#found_count > 0 ?
>> #skip_counts->findposition(#skip)->get(1) | 0);
>>
>>           // determine range of pages to show
>>           #lower = #skip - (#shown_count * #radius);
>>           #upper = #skip + (#shown_count * #radius);
>>
>>           // find previous/next, first/last links
>>           if(#shown_page > 1);        
>>               #prev = '<li><a href="' #base_link '&skip=' (#skip - #shown_count) '"
>> rel="nofollow">&lt;</a></li>';
>>               #first = '<li><a href="' #base_link '&skip=0"
>> rel="nofollow">&lt;&lt;</a></li>';
>>           /if;
>>
>>           if(#shown_page < #skip_counts->size);
>>               #next = '<li><a href="' #base_link '&skip=' (#skip + #shown_count) '"
>> rel="nofollow">&gt;</a></li>';
>>               #last = '<li><a href="' #base_link '&skip=' #skip_counts->last '"
>> rel="nofollow">&gt;&gt;</a></li>';
>>           /if;
>>
>>           // generate individual page nav links
>>           iterate(#skip_counts, local('this'));
>>               if(#this >= #lower && #this <= #upper);
>>                   #display += '<li' (#shown_page == loop_count ? ' class="active"') '>';
>>                   #display += '<a href="' #base_link '&skip=' #this '">' loop_count
>> '</a></li>';
>>               /if;
>>           /iterate;
>>
>>           #out = '<div class="pagination"><ul>' + #first + #prev + (#radius > 0 ?
>> #display) + #next + #last + '</div>\n';
>>
>>           return(@#out);
>>       /if;
>>   /define_tag;
>>   ]
>>
>>
>>
>> On 3/13/14, 2:13 PM, "Jolle Carlestam" <[hidden email]> wrote:
>>
>> I suggest you take a look at Knop grid. It gives you navigation to next,
>> previous, last, first, skip X pages, quick search etc.
>>
>> HDB
>> Jolle
>>
>> Sent from a thin, flat, touchy device from an undetermined place in space.
>>
>>> 14 mar 2014 kl. 04:59 skrev Patrick Larkin <[hidden email]>:
>>>
>>> Sorry for the rudimentary question but I've been unable for years to do
>>> a found set of records with a Next button and Previous button.  I've
>>> tried numerous examples and either am missing something fundamental or
>>> haven't seen a good explanation of how to do it.  I know there were
>>> dedicated tags for this but am I correct that they are not used any
>>> longer?  Usually, this hasn't been an issue because the records returned
>>> in my applications are generally not that high.
>>>
>>> If someone can point me to a good explanation or tutorial on how to do
>>> it, I'd appreciate it.
>>>
>>> Patrick Larkin
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list Lasso [hidden email]
>> Official list archives available at http://www.lassotalk.com
>> To unsubscribe, E-mail to: <[hidden email]>
>> Send administrative queries to  <[hidden email]>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"It's better to burn out than to fade away."

Tami Williams
Creative Computing
Let us help you make frustrating, costly, and inefficient processes more efficient, less costly and scalable.
Lasso, MySQL and FileMaker specialists.

Tel/Fax: 770.457.3221
E-Mail: [hidden email]
Web: http://www.asktami.com/
LinkedIn: http://www.linkedin.com/in/asktami
Twitter: http://twitter.com/asktami
iChat/AIM/Skype: tamiwilliamsusa

FileMaker Business Alliance Member | Lasso Professional Alliance Member | Certified Lasso Developer | FileMaker 11 & 12 Certified Developer

------

If you want to receive sporadic email from Creative Computing regarding news at the company and announcements about upcoming Lasso webinars and online classes, please opt-in at http://tinyurl.com/yj7eqlg

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 Next and Previous

Ke Carlton-3
In reply to this post by Patrick Larkin-2
I don't think custom tags or types are even necessary -- this can be covered
by straight code.

Here's the basic approach I take:

[local(
'page' = integer(client_getparam('page')) || 1,
'max' = 50,
'skip' = (#page - 1) * #max,
'next' = #page + 1,
'prev' = math_max(#page - 1,0)
)]

[inline(-database = 'example',-table = 'page', -maxrecords = #max,
-skiprecords = #skip, -findall)]
 [records]
  [field('whatever')]<br>
[/records]

[if(#skip > 0)]
<a href="?page=[#prev]">Previous</a>
[/if]

[if(found_count > #skip + #max)]
<a href="?page=[#next]">Next</a>
[/if]

[/inline]


Change max accordingly to the number of records you want to display and
everything else just works.

Ke


On 14 March 2014 13:35, Patrick Larkin <[hidden email]> wrote:

> Thanks.  I've tried those tags in the past and couldn't get them to work.
>  I think I just don't understand the code or the logic enough.
>
>
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 Next and Previous

Jussi Hirvi-2
Here is one simple version of the navigation link logic. It may be
helpful in understanding the logic.

Some variables are used, but you will guess their function by their
name. For example #max is [maxrecords_value]. Action param 'skip' is
used to pass the value to the -skiprecords parameter of the search inline.

- Jussi


// link to first page
     if(#shown_first > 2 * #max);
       #out += ' <a class="squarebutton"
href="'+$myfilename+'?ref=naviglinks&';
       #out += #linkstuff+'skip=0" title=';
       #out += '"Go to first page">&laquo;</a>';
     /if;

// link to previous page
    if(#shown_first > #max);
       #out += ' <a class="squarebutton"
href="'+$myfilename+'?ref=naviglinks&';
       #out += #linkstuff+'skip=' + (#shown_first-#max-1) + '" title=';
       #out += '"Go to previous page">&lsaquo;</a>';
     /if;

// link to next page
   #out += '<div id="naviglinks_lowright">\n&nbsp;';
     // skip to next page
     if( #shown_last != #found );
       #out += '<a class="squarebutton"
href="'+$myfilename+'?ref=naviglinks&';
       #out += #linkstuff + 'skip=' + #shown_last + '" title=';
       #out += '"Go to next page">&rsaquo;</a>';
     /if;

     // link to last

     if( #shown_last < #found - #max);
       #out += '<a class="squarebutton"
href="'+$myfilename+'?ref=naviglinks&';
       #out += #linkstuff;
         #max > 0 ? #out += 'skip=' + (#found-(#found % #max)-1);
       #out += '" title="Go to last page">&raquo;</a>';
     /if;
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 Next and Previous

Tami Williams
In reply to this post by Ke Carlton-3
Here's a working example with these links:

<< First Record     < Prev     Showing 3 records out of 7 found ( 4 to 6 )     Next >     Last Record  >>


You can copy the code into a .lasso page and run it.


Here's the MySQL table:

DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
  `first_name` varchar(255) DEFAULT NULL,
  `last_name` varchar(255) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `user_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `contact_name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`user_id`)
) ENGINE=MyISAM AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `users`
--

LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES ('Brian','Dunning','[hidden email]','brian',1,'Brian Dunning'),('Joe','Blow','[hidden email]','joe',2,'Joe Blow'),('Britney','Spears','[hidden email]','britney',3,'Britney Spears'),('Seth','Ganahl','[hidden email]','seth',14,'Seth Ganahl'),('Fred','Flintstone','[hidden email]','fred',17,'Fred Flintstone'),('Wilma','Flintstone','[hidden email]','fred',18,'Wilma Flintstone'),('Jesse','Barnum','[hidden email]','jesse',19,'Jesse Barnum');
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;





*****************************************************


<!DOCTYPE html>
<html>
<head>
        <title>Lasso 8/9 & MySQL - Hitlist - Next and Previous Links Example</title>
</head>
<body>

<?Lassoscript

// required to navigate through found set
var(
'fnd' = 0,
'searchParams' = array,
'navfoundset' = 'navfoundset.inc',
'recSet' = 6,
'maxRec'= 3,
'breakSet' = 2,
'myTableName' = 'users',
'myDbName' = 'masterclass',
'myUSN' = 'masterclass',
'myPWD' = 'masterclass'
);


var(
'page' = integer(action_param('page')) != 0  ? integer(action_param('page')) | 1,
'skip' = ($page - 1) * $maxRec,
'next' = $page + 1,
'prev' = math_max($page - 1,0)
);
?>


<h2>Display Found Set with Next and Previous Links</h2>

[inline(
-inlineName='getRecords',
-Host=(Array(-Datasource='MySQLDS', -Name='127.0.0.1', -Username='root', -Password='admin')), // b/c I have a FM db with the same name as this MySQL table
-database = $myDbName,
-table = $myTableName,
-username = $myUSN,
-password = $myPWD,
-maxRecords=$maxRec,
-skipRecords=$skip,
-sortField = 'last_name',
-sortOrder = 'ascending',
-op = 'NEQ',
'first_name' = 'z',
-search)]
[var('fnd' = found_count)]
Action_Statement = [Action_Statement]
<br>Error_Code error_msg = [Error_Code] [error_msg]


[if(var('fnd') == 0)]

<h3>Sorry! No records matched your search request. Please try your search again.</h3>


[else]

<h3>Here are the [$fnd] records that matched your search request.</h3>

[records]


<!-- display page links -->
[if(loop_count == 1)]


<a href="[Response_FilePath]?page=1">&lt;&lt;&nbsp;First Record</a>
&nbsp;&nbsp;&nbsp;

[if($skip > 0)]
<a href="[Response_FilePath]?page=[$prev]">&lt;&nbsp;Prev</a>
[/if]
&nbsp;&nbsp;&nbsp;

Showing [$maxRec] records out of [found_count] found  ( [math_add(SkipRecords_Value,loop_count)] to  
[(math_min(found_count, $maxRec * $page) )]
)
&nbsp;&nbsp;&nbsp;

[if(found_count > $skip + $maxRec)]
<a href="[Response_FilePath]?page=[$next]">Next&nbsp;&gt;</a>
[/if]
&nbsp;&nbsp;&nbsp;

<a href="[Response_FilePath]?page=[Math_Ceil(decimal(found_count) / decimal($maxRec))]">Last Record &nbsp;&gt&gt</a>

<p>&nbsp;</p>


<!-- display found records in a table -->

<table summary="This table shows the records found using your search criteria." border="1" width="50%" cellspacing="3" cellpadding="4">
<caption>Sort by Clicking on Column Header.</caption>

<thead>
<tr>
<th>&nbsp;</th>
<th scope="col"><strong>First Name</strong></th>

<th scope="col"><strong>Last Name</strong></th>
</tr>
</thead>

<tfoot>
<tr><td colspan="3"><strong>footer</strong></td></tr>
</tfoot>


<tbody>

<!-- end of loop_count == 1 -->
[/if]


<tr>
<td>[math_add(SkipRecords_Value,loop_count)]</td>
<td scope="row">[field('first_name')]</td>
<td>[field('last_name')]</td>
</tr>

[/records]

<!-- end of if found > 0 -->
[/if]

[/inline]
</tbody>
</table>

</body>
</html>




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"It's better to burn out than to fade away."

Tami Williams
Creative Computing
Let us help you make frustrating, costly, and inefficient processes more efficient, less costly and scalable.
Lasso, MySQL and FileMaker specialists.

Tel/Fax: 770.457.3221
E-Mail: [hidden email]
Web: http://www.asktami.com/
LinkedIn: http://www.linkedin.com/in/asktami
Twitter: http://twitter.com/asktami
iChat/AIM/Skype: tamiwilliamsusa

FileMaker Business Alliance Member | Lasso Professional Alliance Member | Certified Lasso Developer | FileMaker 11 & 12 Certified Developer

------

If you want to receive sporadic email from Creative Computing regarding news at the company and announcements about upcoming Lasso webinars and online classes, please opt-in at http://tinyurl.com/yj7eqlg

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: L8.6 Next and Previous

French, Shelane
In reply to this post by Patrick Larkin-2
I forgot that I had also written these tags:

<?LassoScript
define_tag('firstlist', -namespace='skip_');
        if(shown_first > 1);
                return(true);
        else;
                return(false);
        /if;
/define_tag;

define_tag('firstdetail', -namespace='skip_');
        if(shown_first > 1);
                return(true);
        else;
                return(false);
        /if;
/define_tag;

define_tag('prevlist', -namespace='skip_');
        if(shown_first > 1);
                return('skip=' + Math_Max((SkipRecords_Value - MaxRecords_Value), 0));
        else;
                return(false);
        /if;
/define_tag;
define_tag('prevdetail', -namespace='skip_');
        if(shown_first > 1);
                return('skip=' + Math_Max((SkipRecords_Value - 1), 0));
        else;
                return(false);
        /if;
/define_tag;

define_tag('nextlist', -namespace='skip_');
        if(shown_last < found_count);
                return('skip=' + (SkipRecords_Value + MaxRecords_Value));
        else;
                return(false);
        /if;
/define_tag;

define_tag('nextdetail', -namespace='skip_');
        if(shown_first < found_count);
                return('skip=' + (SkipRecords_Value + 1));
        else;
                return(false);
        /if;
/define_tag;

define_tag('lastlist', -namespace='skip_');
        if(shown_last < found_count);
                return('skip=' + Math_Floor((found_count -
1)/MaxRecords_Value)*MaxRecords_Value);
        else;
                return(false);
        /if;
/define_tag;

define_tag('lastdetail', -namespace='skip_');
        if(shown_first < found_count);
                return('skip=' + (found_count - 1));
        else;
                return(false);
        /if;
/define_tag;
?>



I then use them like this:

var('detailurl' = '', 'linkbase' = response_path + '?page=' + $page +
'&sort=' + #sort + '-' + #order));
var('newpage' = (var('listtolist') ? 'list' | 'detail'));
var('firsturl' = (skip_firstlist ? $linkbase | string));
var('prevurl' = (skip_prevlist ? $linkbase + '&' +  skip_prevlist|
string));
var('nexturl' = (skip_nextlist ? $linkbase + '&' +  skip_nextlist|
string));
var('lasturl' = (skip_lastlist ? $linkbase + '&' +  skip_lastlist|
string));

Then use those link variables to output my navigation like so:

<ul>[if($firsturl)]
    <li><a href="[$firsturl]"><i class="icon-step-backward"></i></a></li>
    <li><a href="[$prevurl]"><i
class="icon-chevron-left"></i></a></li>[else]
    <li class="active"><span><i class="icon-step-backward
icon-white"></i></span></li>
    <li class="active"><span><i class="icon-chevron-left
icon-white"></i></span></li>[/if][if($nexturl)]
    <li><a href="[$nexturl]"><i class="icon-chevron-right"></i></a></li>
    <li><a href="[$lasturl]"><i
class="icon-step-forward"></i></a></li>[else]
    <li class="active"><span><i class="icon-chevron-right
icon-white"></i></span></li>
    <li class="active"><span><i class="icon-step-forward
icon-white"></i></span></li>[/if]
    </ul>





On 3/13/14, 5:35 PM, "Patrick Larkin" <[hidden email]> wrote:

Thanks.  I've tried those tags in the past and couldn't get them to work.
I think I just don't understand the code or the logic enough.

Sent from my iPad

> On Mar 13, 2014, at 5:17 PM, "French, Shelane" <[hidden email]> wrote:
>
> This is the tag I have for paginating the results, which is a slight
> modification to a tag Jason Huck wrote. It contains specifics to how I
> want my links to show:
>
> [define_tag(
>        'pagination',
>        -namespace='results_',
>        -required='base_link', -type='string',
>        -opt='found', -type='integer',
>        -opt='shown', -type='integer',
>        -opt='skipped', -type='integer',
>        -opt='range', -type='integer',
>        -priority='replace',
>        -description='Generates links for found set navigation.'
>    );
>        !local_defined('id') ? local('id' = lasso_uniqueid);
>    
>        local(
>            'found_count' = (local_defined('found') ? #found |
>found_count),
>            'shown_count' = (local_defined('shown') ? #shown |
>maxrecords_value),
>            'shown_page' = integer,
>            'skip_counts' = array,
>            'skip' = (local_defined('skipped') ? #skipped |
>skiprecords_value),
>            'counter' = 0,
>            'radius' = 2,
>            'display' = string,
>            'prev' = string,
>            'next' = string,
>            'first' = string,
>            'last' = string,
>            'lower' = integer,
>            'upper' = integer,
>            'out' = string
>        );
>
>        // no navigation is needed if #found_count < #shown_count
>        if(#found_count > #shown_count);
>            // range defaults to 5
>            !local_defined('range') ? local('range' = 5);
>            #radius = #range / 2;
>                  
>            // calculate number of pages
>            local('pages' = #found_count / #shown_count);
>            #found_count % #shown_count > 0 ? #pages += 1;
>            
>            // calculate skip count for each page
>            loop(#pages);
>                #skip_counts->insert(#counter);
>                #counter += #shown_count;
>            /loop;
>            
>            // find the current page
>            #shown_page = (#found_count > 0 ?
> #skip_counts->findposition(#skip)->get(1) | 0);
>    
>            // determine range of pages to show
>            #lower = #skip - (#shown_count * #radius);
>            #upper = #skip + (#shown_count * #radius);
>        
>            // find previous/next, first/last links
>            if(#shown_page > 1);
>                #prev = '<li><a href="' #base_link '&skip=' (#skip -
>#shown_count) '"
> rel="nofollow">&lt;</a></li>';
>                #first = '<li><a href="' #base_link '&skip=0"
> rel="nofollow">&lt;&lt;</a></li>';
>            /if;
>            
>            if(#shown_page < #skip_counts->size);
>                #next = '<li><a href="' #base_link '&skip=' (#skip +
>#shown_count) '"
> rel="nofollow">&gt;</a></li>';
>                #last = '<li><a href="' #base_link '&skip='
>#skip_counts->last '"
> rel="nofollow">&gt;&gt;</a></li>';
>            /if;
>                
>            // generate individual page nav links
>            iterate(#skip_counts, local('this'));
>                if(#this >= #lower && #this <= #upper);
>                    #display += '<li' (#shown_page == loop_count ? '
>class="active"') '>';
>                    #display += '<a href="' #base_link '&skip=' #this
>'">' loop_count
> '</a></li>';
>                /if;
>            /iterate;
>            
>            #out = '<div class="pagination"><ul>' + #first + #prev +
>(#radius > 0 ?
> #display) + #next + #last + '</div>\n';
>            
>            return(@#out);
>        /if;
>    /define_tag;
>    ]
>
>
>
> On 3/13/14, 2:13 PM, "Jolle Carlestam" <[hidden email]> wrote:
>
> I suggest you take a look at Knop grid. It gives you navigation to next,
> previous, last, first, skip X pages, quick search etc.
>
> HDB
> Jolle
>
> Sent from a thin, flat, touchy device from an undetermined place in
>space.
>
>> 14 mar 2014 kl. 04:59 skrev Patrick Larkin <[hidden email]>:
>>
>> Sorry for the rudimentary question but I've been unable for years to do
>> a found set of records with a Next button and Previous button.  I've
>> tried numerous examples and either am missing something fundamental or
>> haven't seen a good explanation of how to do it.  I know there were
>> dedicated tags for this but am I correct that they are not used any
>> longer?  Usually, this hasn't been an issue because the records returned
>> in my applications are generally not that high.
>>
>> If someone can point me to a good explanation or tutorial on how to do
>> it, I'd appreciate it.
>>
>> Patrick Larkin
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>