Blog Joomla How to Change Pagination Style on Joomla or Sobi2

How to Change Pagination Style on Joomla or Sobi2

I'll share about how to change pagination style on Joomla or Sobi2. I've been troubled of how my website pagination looked. At first, i thought i need to fix the codes at Sobi2 component, but in fact, i need to fix the codes on Joomla Core. FYI, i still use Joomla 1.5. The problem is my website pagination was showing too much links 1 to 10, which looked awful on my web design layout because it turns out to be 2 lines. So in order to make it in 1 line, i need to reduce the pagination links to only showing 1 to 4.

So i just need to edit the "libraries\joomla\html\pagination.php".

Find below scripts...

$displayedPages   = 10;
$this->set( 'pages.start', (floor(($this->get('pages.current') -1) / $displayedPages)) * $displayedPages +1);
if ($this->get('pages.start') + $displayedPages -1 < $this->get('pages.total')) {
$this->set( 'pages.stop', $this->get('pages.start') + $displayedPages -1);
} else {
$this->set( 'pages.stop', $this->get('pages.total'));
}

// If we are viewing all records set the view all flag to true
if ($this->limit == $total) {
$this->_viewall = true;
}

 

Replace it to...

$displayedPages   = 4; // not less than 4 and ONLY round numbers like 10, 12, 14...
$this->set( 'pages.start', $this->get('pages.current') - ($displayedPages / 2));
$this->set( 'pages.stop', $this->get('pages.current') + ($displayedPages / 2));
if ($this->get('pages.start') < 1) {
$this->set( 'pages.start', 1);
if ($this->get('pages.total') >= $displayedPages) {
$this->set( 'pages.stop', $this->get('pages.current') + ($displayedPages - $this->get('pages.current')));
}
else {
$this->set( 'pages.stop', $this->get('pages.total'));
}
}
else if ($this->get('pages.start') >= 1) {
if ($this->get('pages.total') <= $displayedPages) {
$this->set( 'pages.start', 1);
$this->set( 'pages.stop', $this->get('pages.total'));
}
else if ($this->get('pages.total') > $displayedPages) {
if ( ($this->get('pages.total') - $this->get('pages.current')) < ($displayedPages / 2) ){
$this->set( 'pages.start', $this->get('pages.current') - ( ($displayedPages - 1) - ($this->get('pages.total') - $this->get('pages.current'))) );
$this->set( 'pages.stop', $this->get('pages.total'));
}
}
}

 

In my case, i only need to show 4 links, so on "$displayedPages   = 4;" i putted there "4". You can change it to however you want, based on your needs.

You can check the result of my work at garasi24.com.

Source : forum.joomla.org


blog comments powered by Disqus

Blog

blog image

Firefox Quantum, Download dan Rasakan Kecepatannya!

Mozilla baru saja meluncurkan Firefox Quantum, browser Firefox yang menggunakan engine baru. Mozilla juga menyajikan konsep design UI yang baru yang disebut sebagai Photon. Anda tidak percaya? Silahkan coba Download Firefox Quantum dan rasakan perbedaannya!

Read more

blog image

eCommerce vs Marketplace

Sebagai salah satu pelaku industri, saya hendak melakukan riset secara langsung, bagaimana rasanya dan bagaimana perbedaan antara berjualan lewat website online store sendiri atau ecommerce, dibandingkan dengan menggunakan marketplace yang sudah begitu banyak bertebaran saat ini. Oleh karena itu sejak setahun terakhir, saya mencoba melakukan kegiatan jual beli

Read more

blog image

How to Build a Successful Business

Someone just emailed me, asking about my successful freelance career. Well, i know that i'm still far from success in build my own web design company. But if talking about success with my freelance career as web designer, i think it's a target that i already achieved few

Read more

blog image

Marvel App, Aplikasi Untuk Membuat Prototype Tanpa Coding

Beberapa waktu lalu saya diperkenalkan dengan sebuah aplikasi yang ternyata sesuai dengan yang selama ini saya cari dan belum ketemu. Aplikasi yang cocok untuk kalian yang punya bakat design, namun lemah di coding, seperti saya. Marvel App bisa membantu membuat...

Read more

Hello!

Yofie Setiawan

My name is Yofie, I manage a solid team of web designers and web developers based in Jakarta, Indonesia. We are experts in building websites with Joomla CMS and are able to build websites using Responsive Web Design technology. If you are interested in hiring us for a project, Contact Us!

Contact Us

PT. Yopdesign Creative Indonesia
Gedung Tifa, Annex Suite
Jl. Kuningan Barat I No.26
Mampang Prapatan - Jakarta 12710

+62 859 5959 8224
[email protected]

whatsapp whatsapp