Pagination issue

rve66

Joined: 2009-09-10
Posts: 31
Posted: Thu, 2009-10-01 15:20

Hi,

how can i set pagination to "digg"????
Looking at http://docs.kohanaphp.com/libraries/pagination
the 'digg' style would give me what I want but so far
unable to get this working in G3!
Am is missing something here? I guess so :-(

-RvE

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Thu, 2009-10-01 15:54

I've been trying to figure that out, but haven't had much time since 9/27

If you hit the IRC logs from 9/27 you'll see the conversation I was having with talmdal and bharat to get some help there:
http://codex.gallery2.org/IRC
http://tools.gallery2.org/

Here's the meat of the end of the conversation, basically we're not using Kohana's pagination right now, but use to so finding some old files (see the git repo) would be the starting path:

Quote:
18:54 <+talmdal> nivekiam: i think the stumbling block is we are overriding the pagination generation with crating our own view
18:54 <+talmdal> *creating
18:55 <+bharat> yes. we're not using the kohana pagination anymore
18:55 <+bharat> we used to, but in one of the ui rewrite thumb or jhilden whacked it
18:56 <+talmdal> nivekiam: better idea
18:56 <+talmdal> find the original style template and replace pager.html.php with it
18:57 <+bharat> there are complications
18:57 <+bharat> we do different things for album vs photo pagination

19:00 <+nivekiam> yeah, just noticed that I was refreshing a photo page and not seeing any changes
19:00 <+nivekiam> go back to an album page and it's not working :)
19:01 <+talmdal> nivekiam: if u really want to play with it, take a look at gallery3-vendor/kohana/system/views/pagination

I haven't found the time to go back to that though.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2139
Posted: Thu, 2009-10-01 17:31

I went through the current code and I am under impression that current Kohana is actually old.
Kohana 3.0 released on 2009-09-16, but from kohana.php we use 2009-05-28.

May be reason is that we are not latest codebase?

From the page above, we should have all default styles provided by Kohana, yet current codebase only have 'default' style.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Thu, 2009-10-01 17:40

That's not the reason. Follow the links I posted.

There is, however, a reason (or several) why we are not using Kohana 3.0. I don't know them off the top of my head, but feel free to join the -devel mailing list and ask or search the archives or join in on #gallery and ask there or search the IRC logs, or post a thread specifically about that in the forums. :) I'm not a developer and wasn't directly involved in that decision. I believe it may have been that we were headed down the path of using Kohana before 3.0 was released and upgrading is apparently not a simple matter. It also appears there is a rift in the Kohana community about some decisions that were made on that front.

http://codex.gallery2.org/Mailing_Lists
http://www.nabble.com/forum/Search.jtp?forum=3818&local=y&query=kohana
http://codex.gallery2.org/IRC
http://tools.gallery2.org/

There is someone from the Kohana community how hangs out in #gallery quite a bit. I don't now if he's just a user or Kohana developer or what though.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2139
Posted: Thu, 2009-10-01 17:43

This is the code for digg style (from kohana)
It need to be adopted for G3 style though. I will try incorporate it in my theme some time soon

Quote:
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Digg pagination style
*
* @preview « Previous 1 2 ... 5 6 7 8 9 10 11 12 13 14 ... 25 26 Next »
*/
?>

<p class="pagination">
<?php if ($previous_page): ?>
<a href="<?php echo str_replace('{page}', $previous_page, $url) ?>">&laquo;&nbsp;<?php echo Kohana::lang('pagination.previous') ?></a>
<?php else: ?>
&laquo;&nbsp;<?php echo Kohana::lang('pagination.previous') ?>
<?php endif ?>

<?php if ($total_pages < 13): /* « Previous 1 2 3 4 5 6 7 8 9 10 11 12 Next » */ ?>

<?php for ($i = 1; $i <= $total_pages; $i++): ?>
<?php if ($i == $current_page): ?>
<strong><?php echo $i ?></strong>
<?php else: ?>
<a href="<?php echo str_replace('{page}', $i, $url) ?>"><?php echo $i ?></a>
<?php endif ?>
<?php endfor ?>

<?php elseif ($current_page < 9): /* « Previous 1 2 3 4 5 6 7 8 9 10 ... 25 26 Next » */ ?>

<?php for ($i = 1; $i <= 10; $i++): ?>
<?php if ($i == $current_page): ?>
<strong><?php echo $i ?></strong>
<?php else: ?>
<a href="<?php echo str_replace('{page}', $i, $url) ?>"><?php echo $i ?></a>
<?php endif ?>
<?php endfor ?>

&hellip;
<a href="<?php echo str_replace('{page}', $total_pages - 1, $url) ?>"><?php echo $total_pages - 1 ?></a>
<a href="<?php echo str_replace('{page}', $total_pages, $url) ?>"><?php echo $total_pages ?></a>

<?php elseif ($current_page > $total_pages - 8): /* « Previous 1 2 ... 17 18 19 20 21 22 23 24 25 26 Next » */ ?>

<a href="<?php echo str_replace('{page}', 1, $url) ?>">1</a>
<a href="<?php echo str_replace('{page}', 2, $url) ?>">2</a>
&hellip;

<?php for ($i = $total_pages - 9; $i <= $total_pages; $i++): ?>
<?php if ($i == $current_page): ?>
<strong><?php echo $i ?></strong>
<?php else: ?>
<a href="<?php echo str_replace('{page}', $i, $url) ?>"><?php echo $i ?></a>
<?php endif ?>
<?php endfor ?>

<?php else: /* « Previous 1 2 
 5 6 7 8 9 10 11 12 13 14 
 25 26 Next » */ ?>

<a href="<?php echo str_replace('{page}', 1, $url) ?>">1</a>
<a href="<?php echo str_replace('{page}', 2, $url) ?>">2</a>
&hellip;

<?php for ($i = $current_page - 5; $i <= $current_page + 5; $i++): ?>
<?php if ($i == $current_page): ?>
<strong><?php echo $i ?></strong>
<?php else: ?>
<a href="<?php echo str_replace('{page}', $i, $url) ?>"><?php echo $i ?></a>
<?php endif ?>
<?php endfor ?>

&hellip;
<a href="<?php echo str_replace('{page}', $total_pages - 1, $url) ?>"><?php echo $total_pages - 1 ?></a>
<a href="<?php echo str_replace('{page}', $total_pages, $url) ?>"><?php echo $total_pages ?></a>

<?php endif ?>

<?php if ($next_page): ?>
<a href="<?php echo str_replace('{page}', $next_page, $url) ?>"><?php echo Kohana::lang('pagination.next') ?>&nbsp;&raquo;</a>
<?php else: ?>
<?php echo Kohana::lang('pagination.next') ?>&nbsp;&raquo;
<?php endif ?>

</p>

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Thu, 2009-10-01 17:47

oh and read my post above, we were using Kohana pagination directly, but are not any longer. Talmdal and Bharat both post what we'd need to do to go back to using Kohana pagination.

You can find old versions of the code here: http://github.com/gallery/gallery3/commits/master/themes/default/views/pager.html.php

Again, I've barely even started digging into this.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Thu, 2009-10-01 17:54
Quote:
It need to be adopted for G3 style though. I will try incorporate it in my theme some time soon

COOL! I'd love to see that. And learn from what you come up with.

Thanks for all of your contributions Serge! It does help out.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2139
Posted: Thu, 2009-10-01 17:55

@nivekiam: I am in the list, but I have no time available to spend there, sorry.
I've heard about the rift... politics :)

Going through the code above (kohana style), default logic is all text, there is no room for styles there. I think it is one reason no to use default kohana adapter.
But what can be done is a port of logic above for G3. And this what I am going concentrate on.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16503
Posted: Thu, 2009-10-01 18:02
Quote:
I've heard about the rift... politics

Which just sucks for all involved...

Quote:
But what can be done is a port of logic above for G3. And this what I am going concentrate on.

Great! I'm glad you can see that better than I can. I thought about that, then looked at what I think was the same example as you posted and just didn't see it :) But you work with code more than I do.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
rve66

Joined: 2009-09-10
Posts: 31
Posted: Thu, 2009-10-01 19:24

Put this in pager.html.php, for me it seems to work (table is used to make it visible and style I leave to others to use own style :-))

<table border="2">
<tr>
<td>

<p class="pagination">
<? if ($previous_page): ?>
<a href="<?= str_replace('{page}', $previous_page, $url) ?>">&laquo;&nbsp;<?= t("previous") ?></a>
<? else: ?>
&laquo;&nbsp;<?= t("previous") ?>
<? endif; ?>
</p>
</td>
<td>

<? if ($total_pages < 13): ?>

<? for ($i = 1; $i <= $total_pages; $i++): ?>
<? if ($i == $current_page): ?>
<strong><?= t( $i ) ?></strong>
<? else: ?>
<a href="<?= str_replace('{page}', $i, $url) ?>"><?= t( $i ) ?></a>
<? endif; ?>
<? endfor ?>

<? elseif ($current_page < 9): ?>

<? for ($i = 1; $i <= 10; $i++): ?>
<? if ($i == $current_page): ?>
<strong><?= t( $i ) ?></strong>
<? else: ?>
<a href="<?= str_replace('{page}', $i, $url) ?>"><?= t( $i ) ?></a>
<? endif; ?>
<? endfor ?>

&hellip;
<a href="<?= str_replace('{page}', $total_pages - 1, $url) ?>"><?= t( $total_pages - 1 ) ?></a>
<a href="<?= str_replace('{page}', $total_pages, $url) ?>"><?= t( $total_pages ) ?></a>

<? elseif ($current_page > $total_pages - 8): ?>

<a href="<?= str_replace('{page}', 1, $url) ?>">1</a>
<a href="<?= str_replace('{page}', 2, $url) ?>">2</a>
&hellip;

<? for ($i = $total_pages - 9; $i <= $total_pages; $i++): ?>
<? if ($i == $current_page): ?>
<strong><?= t( $i ) ?></strong>
<? else: ?>
<a href="<?= str_replace('{page}', $i, $url) ?>"><?= t( $i ) ?></a>
<? endif; ?>
<? endfor ?>

<? else: ?>

<a href="<?= str_replace('{page}', 1, $url) ?>">1</a>
<a href="<?= str_replace('{page}', 2, $url) ?>">2</a>
&hellip;

<? for ($i = $current_page - 5; $i <= $current_page + 5; $i++): ?>
<? if ($i == $current_page): ?>
<strong><?= t( $i ) ?></strong>
<? else: ?>
<a href="<?= str_replace('{page}', $i, $url) ?>"><?= t( $i ) ?></a>
<? endif; ?>
<? endfor ?>

&hellip;
<a href="<?= str_replace('{page}', $total_pages - 1, $url) ?>"><?= t( $total_pages - 1 ) ?></a>
<a href="<?= str_replace('{page}', $total_pages, $url) ?>"><?= t( $total_pages ) ?></a>

<? endif; ?>

</td>
<td>
<? if ($next_page): ?>
<a href="<?= str_replace('{page}', $next_page, $url) ?>"><?= t("next") ?>&nbsp;&raquo;</a>
<? else: ?>
<?= t("next") ?>&nbsp;&raquo;
<? endif; ?>
</td>
</tr>
</table>

Thank you Serge for pointing to the needed basic code :-)

-RvE

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2139
Posted: Thu, 2009-10-01 19:53

@rve66: this is basic, text only code from Kohana distro itself.
If anyone interested in other styles mentioned in original article, just use google :).
I want to point on the fact that this is a starting point for the authors, while next step would be to adjust a markup to follow theme's style.

 
rve66

Joined: 2009-09-10
Posts: 31
Posted: Thu, 2009-10-01 20:23

@SergeD: I understand you wrote it in original entry but also it need worked on.
I adjusted the code and the pagination is working like wanted (digg like) I did not added styling arround it because I think thats up to everyone itself. For me it's styled like my page is NewClassic!

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2139
Posted: Thu, 2009-10-01 20:42

Oh, yes I've noticed that. :) You use tables as well which is not a style of G3 :) but it is a different topic.
My point was that for this code to be seamless for default theme, it need to be adjusted to use <span> syntax to make up buttons.

You have a good code nevertheless.

 
rve66

Joined: 2009-09-10
Posts: 31
Posted: Thu, 2009-10-01 21:05

Yeah I noticed already tables are not used to much in G3 (they are there but not much)
And yes its other topic (table or not :-)) maybe give me a pm what you think about it!

In case of this sample I only used the TABLE option with a BORDER="2" in order for others to find simply the place to adjust it for there needs.

Sure to make it like all other things it should be more DIV UL LI SPAN style. Maybe i will do it completly like this on my site but for know I have what I wanted digg style :-)

Any way, it was your theme made me happy to work on G3. At first I was not happy with G3 but once I saw your first theme work I turned and am now to go for G3 only (still needs worked on but well we also can help and I think we do by adding at first stage custom themes right)

In the end I think both do what we like. We do have questions about the product but we also contribute, as far as we can, to the product (I hope) right!

 
Serge D
Serge D's picture

Joined: 2009-06-11
Posts: 2139
Posted: Fri, 2009-10-02 18:00

Ok, I think I got it working with my theme.
pager.html.php is available here http://codex.gallery2.org/Gallery3:Themes:greydragon as Hotfix20091002-2.zip

 
rve66

Joined: 2009-09-10
Posts: 31
Posted: Sat, 2009-10-03 11:11

I am going to put it into my theme to.
So far I looked and it looks nice (much better as my quick solution)
I will update once I have the results.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 22890
Posted: Sun, 2009-11-15 04:23

Please look at recent changes to pagination:
http://github.com/gallery/gallery3/commit/081ce9f6ca07b834fd31d3d340990504dd68f821
&
http://github.com/gallery/gallery3/commit/29efb6ba9f3e2cf15f29b509f985890c33bc08fa
New ways of pagination, documented in the files for theme developers.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team