Skip to main content
Topic: Pagination for ssi_boardNews();? (Read 3402 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Pagination for ssi_boardNews();?

Would be possible to add pagination for ssi_boardNews(); function?
I had no luck with it so far.. :|

Re: Pagination for ssi_boardNews();?

Reply #1

If you don't want to modify SSI you can just query {db_prefix}boards and grab the number of topics.
Otherwise you can modify the query after the comment
Code: [Select]
// Make sure guests can see this board.
including the column with the number of topics. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: Pagination for ssi_boardNews();?

Reply #2

well, I took number of topics from
Code: [Select]
count($return

but when, then I used constructPageIndex, but when I click on page it sends mo to let's say 2 page, but then I have only one page in pagination.

News will be loaded from board that guest can see, so I'm thinking maybe I will use custom query t do this.. ::)

Re: Pagination for ssi_boardNews();?

Reply #3

If you count the returned topics you will get only as much topics as you retrieved, so 1 page in any case. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: Pagination for ssi_boardNews();?

Reply #4

ok.. ::) My mistake :) I'll try to figure it out later, thanks

Re: Pagination for ssi_boardNews();?

Reply #5

I have to remove check for who can see board otherwise it's not possible to get num_topics as value in array?

Re: Pagination for ssi_boardNews();?

Reply #6

How are you trying to get it?
Bugs creator.
Features destroyer.
Template killer.

Re: Pagination for ssi_boardNews();?

Reply #7

I added this query:
Code: [Select]
	// Make sure guests can see this board.
$request = $db->query('', '
SELECT id_board, num_topics
FROM {db_prefix}boards
WHERE id_board = 1
LIMIT 1',
array()
);
$c = $db->fetch_row($request);
$db->free_result($request);
$total_news_items = $c[1];

list() was returning array, but without number of topics

Re: Pagination for ssi_boardNews();?

Reply #8

ok, I think that I got it right way now:
Code: [Select]
	// Make sure guests can see this board.
$request = $db->query('', '
SELECT id_board, num_topics
FROM {db_prefix}boards
WHERE ' . ($board === null ? '' : 'id_board = {int:current_board}
AND ') . 'FIND_IN_SET(-1, member_groups) != 0
LIMIT 1',
array(
'current_board' => $board,
)
);
if ($db->num_rows($request) == 0)
{
if ($output_method == 'echo')
die($txt['ssi_no_guests']);
else
return array();
}
list ($board, $num_topics) = $db->fetch_row($request);
$db->free_result($request);

$total_news_items = $num_topics;

Re: Pagination for ssi_boardNews();?

Reply #9

Yep, that how to change SSI to get the num_topics too. ;D
Bugs creator.
Features destroyer.
Template killer.

Re: Pagination for ssi_boardNews();?

Reply #10

Is there any way to get pages as array? I would like use custom template, but only for this SSI page.

Re: Pagination for ssi_boardNews();?

Reply #11

I't something I considered a while ago, but the resulting array was rather ugly and difficult to use.
May I ask exactly what kind of custom templating you want to apply?
There are already a lot of classes attached to each element, it should be enough to style almost everything (at least I was told so, not that I ever tried and probably I wouldn't even be able, but that's another problem).

In case, you can replace the styles by changing the 'page_index_template' of the $settings array, something like that:
Code: [Select]
$tmp_pagination = $settings['page_index_template'];
$settings['page_index_template'] = array(
    // the various elements, see template_init in index.template.php for details
);
$context['page_index'] = contrusctPageIndex(/* bla bla */);
$settings['page_index_template'] = $tmp_pagination;
Bugs creator.
Features destroyer.
Template killer.

Re: Pagination for ssi_boardNews();?

Reply #12

I just wanted to replace previous next labels with < and >. It seems that it doesn't work for me :| I will find a way to change CSS for buttons.

Re: Pagination for ssi_boardNews();?

Reply #13

Oh, okay, these are text strings.
I'd use the same trick to replace the $txt variables.
Bugs creator.
Features destroyer.
Template killer.

Re: Pagination for ssi_boardNews();?

Reply #14

I couldn't make it work with custom templates, so I just defined $txt['next'] and $txt['prev'] on SSI page.

Thanks for help :)