ElkArte Community

Elk Development => Feature Discussion => Topic started by: Adrek on September 09, 2014, 09:25:39 am

Title: Pagination for ssi_boardNews();?
Post by: Adrek on September 09, 2014, 09:25:39 am
Would be possible to add pagination for ssi_boardNews(); function?
I had no luck with it so far.. :|
Title: Re: Pagination for ssi_boardNews();?
Post by: emanuele on September 09, 2014, 09:36:47 am
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. ;)
Title: Re: Pagination for ssi_boardNews();?
Post by: Adrek on September 09, 2014, 09:41:31 am
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.. ::)
Title: Re: Pagination for ssi_boardNews();?
Post by: emanuele on September 09, 2014, 09:49:11 am
If you count the returned topics you will get only as much topics as you retrieved, so 1 page in any case. ;)
Title: Re: Pagination for ssi_boardNews();?
Post by: Adrek on September 09, 2014, 09:55:01 am
ok.. ::) My mistake :) I'll try to figure it out later, thanks
Title: Re: Pagination for ssi_boardNews();?
Post by: Adrek on September 09, 2014, 04:34:36 pm
I have to remove check for who can see board otherwise it's not possible to get num_topics as value in array?
Title: Re: Pagination for ssi_boardNews();?
Post by: emanuele on September 09, 2014, 04:38:07 pm
How are you trying to get it?
Title: Re: Pagination for ssi_boardNews();?
Post by: Adrek on September 09, 2014, 04:45:35 pm
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
Title: Re: Pagination for ssi_boardNews();?
Post by: Adrek on September 09, 2014, 04:53:20 pm
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;
Title: Re: Pagination for ssi_boardNews();?
Post by: emanuele on September 09, 2014, 05:26:16 pm
Yep, that how to change SSI to get the num_topics too. ;D
Title: Re: Pagination for ssi_boardNews();?
Post by: Adrek on September 09, 2014, 05:35:54 pm
Is there any way to get pages as array? I would like use custom template, but only for this SSI page.
Title: Re: Pagination for ssi_boardNews();?
Post by: emanuele on September 10, 2014, 03:14:04 am
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;
Title: Re: Pagination for ssi_boardNews();?
Post by: Adrek on September 10, 2014, 08:08:27 am
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.
Title: Re: Pagination for ssi_boardNews();?
Post by: emanuele on September 10, 2014, 08:57:26 am
Oh, okay, these are text strings.
I'd use the same trick to replace the $txt variables.
Title: Re: Pagination for ssi_boardNews();?
Post by: Adrek on September 10, 2014, 12:56:20 pm
I couldn't make it work with custom templates, so I just defined $txt['next'] and $txt['prev'] on SSI page.

Thanks for help :)
Title: Re: Pagination for ssi_boardNews();?
Post by: emanuele on December 02, 2014, 04:25:09 am
Bump as reminder.