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
Quote Reply
Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar In reply to
I forgot to mention that I only added the paging_pre, paging_post options today, so the RC (2.99.1) actually doesn't have those options. It's not a big deal so I won't bother releasing an update for it, but if anyone really wants it, I can put out an update for it.

Adrian
Quote Reply
Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar In reply to
It could make this? Wink

Last edited by:

Janio: Apr 1, 2005, 9:51 AM
Quote Reply
Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar In reply to
Hehe, that's similar solution to what I did in one of my plugins Cool

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] GLinks 3.x HOWTO: Customising the paging toolbar In reply to
How can i send the last link to the first one and vice versa.
When i use paging on detailed it stops at start and end; fpr my site it makes more sense to go in a circle from last to first and frist to last. Has anyone solved this before?
Quote Reply
Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar In reply to
Can you please help me understand how can I change font size/weight/type for pagging options.

Pages : 1 2 3 4 5 6 7 8 9 10 ... 64 [>] [>>]


Thank you.

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] GLinks 3.x HOWTO: Customising the paging toolbar In reply to
That is all controlled using CSS. Take a look at the source of the paging html and the css.

Adrian
Quote Reply
Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar In reply to
I am not using luna template, instead have created everything from scratch. So what code do I need to add in my created css file to edit this? if you have the answer handy, it would be very much appreciated, else I might have to dig into luna template and its css file to find this one tag.

Thanks for the help.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] GLinks 3.x HOWTO: Customising the paging toolbar In reply to
Well, it's all just basic CSS, just create your rules based on the generated html and how you want to style it.

Adrian
Quote Reply
Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar In reply to
I am not able to use formatting with custom css tags within category.html

Here are the tags that I am using

in category.html
Quote:
<%if paging.num_hits%><div class="rightalign"><%Links::Utils::paging(button_id => 'paging_button3')%><br></div><%endif%>


paging_options global
Quote:
sub {
return {
max_pages => 5,
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: ",
};
}


Now if I am not wrong pages & numbers are generated by <%Links::Utils::paging(button_id => 'paging_button3')%> and I have no idea how to apply formatting for that (I am wanting to give it different look, than the default a.link tags). Any thoughts?

Thanks for the help.

Vishal
-------------------------------------------------------
Quote Reply
Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar In reply to
I just want to have the word "NEXT" instead of the whole paging toolbar "[<<][<] 1 2 3 [>][>>]"
and wanted to be able to click last "NEXT" on the last page to go to a specific category.

something like NEXT --- NEXT ---- NEXT (no previous, no page counts nothing.. just NEXT to move forward).

Any idea... how to accomplish this one.. thanks much in advance...
Code:

sub {
return {
max_pages => 1,
boundary_pages => 1,
style => 3,
style_next => "Next",
style_prev => "",
style_first => "",
style_last => "",
style_nonext => "<a href="/cgi/links/page.cgi?g=46/index.html;d=1">Start Here Again</a>",
style_noprev => "",
style_nofirst => "",
style_nolast => "",
paging_pre => "",
};
}
Quote Reply
Re: [brewt] GLinks 3.x HOWTO: Customising the paging toolbar In reply to
Hi,

It is possible to modify the style for current_page ?

I currently have, <span>$_</span> and I would like to obtain <span class="current" >$_</span>.

Which is the best option ?

I would like to avoid modifying the Utils.pm file.

Thanks for your assistance.

Mick