Gossamer Forum
Home : Products : Gossamer Links : Discussions :

GLinks 3.x HOWTO: Customising the paging toolbar

Quote Reply
GLinks 3.x HOWTO: Customising the paging toolbar
In Gossamer Links 3.x, we've moved most of the html generation into the templates. For the html that is still generated in the code, we've tried to make it as customisable as possible as well as allow the code to be overridden if needed. With the paging toolbar, the html is generated by a call to Links::Utils::paging. Customisation of the paging toolbar is done through passing options to the paging function.

Links::Utils::paging allows options to be passed in in two ways: as arguments passed in during the function call, and through the global "paging_options." Passing them in through paging_options is the preferred method since no template changes are required. The default paging_options global is as follows:
Code:
sub {
return {
max_pages => 25,
boundary_pages => 1,
style => 1,
};
}
To add more options, just use the syntax (note that this is Perl code, so Perl syntax rules apply): "<option_name> => <option_value>,"

There are a variety of options which allow you to customise your paging toolbars. Here's a list of the options:
  • style: by default, there are 3 paging styles available (we may add more in the future). You can choose the style that you like best.
    1. first/last, previous/next pages with page selection:

      Using javascript, it will go to the selected page on selection.
    2. previous/next pages with page selection:

      Like style 1, it will go to the selected page on selection.
    3. 'classic' paging:
    Note that styles 1 and 2 use javascript on the select element to change pages. If javascript is not enabled, then a Go button is shown. An example of what style 1 would look without javascript would be like this:

  • max_pages: this number controls the maximum number of pages to display (not including the boundary pages). This is set to 25 by default, and in the style 3 example, it has been set to 10.

  • boundary_pages: this number controls the number of boundary pages that will be added if the number of pages exceeds the max_pages option. In the examples above, it has been set to 1.

  • style_next, style_prev, style_first, style_last, style_nonext, style_noprev, style_nofirst, style_nolast: these options allow you to change what's shown for the next/prev/etc actions. You can use these options to change the images into plain text, change the images, or just change the title tags of the images. Take a look at Links::Utils::paging for the defaults.

  • lang_of: for styles 1 and 2, they use the format of "<page> <lang_of> <page>" for the drop down. This option allows you to change the text "of" to something else.

  • lang_button: for styles 1 and 2, a "Go" button is used for users which do not have javascript support. This option allows you to change the button's label.

  • button_id: if you've got two paging toolbars on a page, then you will need to change the button_id so that the javascript can remove the button. This is used on the bottom paging toolbar. Most users will not need to set this option.

  • paging_pre, paging_post: this text or html is added before and after the paging html. For example, you could use this option to append the text "Page: " to the toolbar.

Here's an example of making the paging toolbar look even more like the one used in Links SQL 2.x:

Code:
sub {
return {
max_pages => 10,
boundary_pages => 1,
style => 3,
style_next => "[&gt;]",
style_prev => "[&lt;]",
style_first => "[&lt;&lt;]",
style_last => "[&gt;&gt;]",
style_nonext => "",
style_noprev => "",
style_nofirst => "",
style_nolast => "",
paging_pre => "Pages: ",
};
}
You may also create your own paging styles by overriding the paging code. This is done by creating a 'paging_override' global. See the comments in Links::Utils::paging for more information.

Adrian

Last edited by:

Inertia: Oct 29, 2008, 5:10 PM
Subject Author Views Date
Thread GLinks 3.x HOWTO: Customising the paging toolbar brewt 16984 Mar 28, 2005, 5:08 PM
Thread Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar
brewt 16646 Mar 28, 2005, 8:36 PM
Post Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar
Janio 16508 Apr 1, 2005, 9:49 AM
Thread Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar
webmaster33 16538 Apr 12, 2005, 11:27 AM
Post Re: [webmaster33] GLinks 3.x HOWTO: Customising the paging toolbar
Robert 16389 May 18, 2005, 7:17 PM
Thread Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar
VishalT 16152 Mar 19, 2006, 12:04 PM
Thread Re: [SWDevil.Com] GLinks 3.x HOWTO: Customising the paging toolbar
brewt 16144 Mar 19, 2006, 12:38 PM
Thread Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar
VishalT 16077 Mar 19, 2006, 12:42 PM
Thread Re: [SWDevil.Com] GLinks 3.x HOWTO: Customising the paging toolbar
brewt 16116 Mar 19, 2006, 12:54 PM
Post Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar
VishalT 16062 Mar 19, 2006, 1:29 PM
Post Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar
Mark2 15941 Oct 5, 2006, 2:14 PM
Post Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar
MJ_ 15484 Oct 25, 2008, 6:02 AM