Skip to content

Commit

Permalink
some work on pagers.
Browse files Browse the repository at this point in the history
  • Loading branch information
laceysanderson committed Oct 15, 2019
1 parent 67fad2c commit 9012ceb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions includes/tripal_hq_admin_dashboard.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function tripal_hq_admin_dashboard_form(array $form, array &$form_state, $status
global $user;
$uid = $user->uid;

$items_per_page = 10;

$form['instructions'] = ['#markup' => $message];

$header = [
Expand Down Expand Up @@ -80,7 +82,7 @@ function tripal_hq_admin_dashboard_form(array $form, array &$form_state, $status

$requests = $query->fields('t')
->orderBy('id', 'desc')
->limit(10)
->limit($items_per_page)
->execute()
->fetchAll();
}
Expand All @@ -95,7 +97,7 @@ function tripal_hq_admin_dashboard_form(array $form, array &$form_state, $status
}
$requests = $query->fields('t')
->orderBy('id', 'desc')
->limit(10)
->limit($items_per_page)
->execute()
->fetchAll();
}
Expand Down Expand Up @@ -144,7 +146,6 @@ function tripal_hq_admin_dashboard_form(array $form, array &$form_state, $status

$form['pager'] = [
'#theme' => 'pager',
'#quantity' => 5,
];

// Now we add in an alter hook to allow submodules to add to this dashboard.
Expand Down
8 changes: 7 additions & 1 deletion includes/tripal_hq_user_dashboard.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function tripal_hq_user_dashboard_form($form, &$form_state) {
global $user;
$uid = $user->uid;

$items_per_page = 5;

$header = [
'Title' => [
'data' => t('Title'),
Expand Down Expand Up @@ -45,7 +47,7 @@ function tripal_hq_user_dashboard_form($form, &$form_state) {
->extend('TableSort')
->orderByHeader($header)
->extend('PagerDefault')
->limit(20)
->limit($items_per_page)
->execute()
->fetchAll();

Expand Down Expand Up @@ -108,6 +110,10 @@ function tripal_hq_user_dashboard_form($form, &$form_state) {
'#empty' => t("You have no pending content submissions."),
];

$form['pager'] = [
'#theme' => 'pager',
];

// Now we add in an alter hook to allow submodules to add to this dashboard.
// To use this after hook in your own module create a function named
// [yourmodule]_tripal_hq_user_dashboard_alter($form, $form_state) {}
Expand Down

0 comments on commit 9012ceb

Please sign in to comment.