Reference - Data handling - page


App: manual - Page: fragments/pager_1
PHP
fragments/pager_1.php
HTML
fragments/pager_1.pad
Result
<?php

$products
= range ( 1, 47 );

?>
{products page=$pg ?? 1, rows=5}
{$products}
{/products}

{pager 'products', window=1}


App: manual - Page: fragments/pager_2
PHP
fragments/pager_2.php
HTML
fragments/pager_2.pad
Result
<?php

$products
= range ( 1, 47 );

?>
{products page=$p ?? 1, rows=10}{/products}

{pager 'products'}
{if $href eq ''}
<span>{$label}</span>
{elseif $kind eq 'current'}
<strong>{$label}</strong>
{else}
<a href="{$href}">{$label}</a>
{/if}
{/pager}


App: manual - Page: miscellaneous/handling


App: regression/framework - Page: options/a_page_below_one_is_the_first_page
PHP
options/a_page_below_one_is_the_first_page.php
HTML
options/a_page_below_one_is_the_first_page.pad
Result
<?php

$items
= [ [ 'n' => 1 ], [ 'n' => 2 ], [ 'n' => 3 ] ];
$pg = 'abc';

?>
{items page=0, rows=2}{$n} {/items}|{items page=-1, rows=2}{$n} {/items}|{items page=$pg, rows=2}{$n} {/items}|{items page=2, rows=2}{$n} {/items}


App: regression/framework - Page: options/a_paged_tag_leaves_now_and_hit_alone
PHP
options/a_paged_tag_leaves_now_and_hit_alone.php
HTML
options/a_paged_tag_leaves_now_and_hit_alone.pad
Result
<?php

$now
= 'app now';
$hit = 'app hit';

?>
{data 'pg'}[{"n":"a"},{"n":"b"},{"n":"c"}]{/data}{pg page=2, rows=2}{$n}{/pg}|{$now}|{$hit}


App: regression/framework - Page: options/negative_inverts_the_window_page_or_start_cut_with_rows_or_end
PHP
HTML
options/negative_inverts_the_window_page_or_start_cut_with_rows_or_end.pad
Result
{data 'n'}
[1,2,3,4,5]
{/data}
[{n page=2, rows=2, negative}
{$n},
{/n}][{n rows=2, page=2, negative}
{$n},
{/n}][{n start=2, end=3, negative}
{$n},
{/n}][{n start=2, rows=2, negative}
{$n},
{/n}][{n end=-1, rows=2, negative}
{$n},
{/n}][{n rows=2, negative}
{$n},
{/n}]


App: regression/framework - Page: options/negative_keeps_the_rows_outside_a_window_sized_beside_it
PHP
HTML
options/negative_keeps_the_rows_outside_a_window_sized_beside_it.pad
Result
{data 'xs'}
[1,2,3,4,5,6]
{/data}
[{xs page=2, rows=2, negative}{$xs}{/xs}]
[{xs start=2, end=4, negative}{$xs}{/xs}]
[{xs end=3, rows=2, negative}{$xs}{/xs}]


App: regression/framework - Page: options/page_moves_along_by_that_many
PHP
HTML
options/page_moves_along_by_that_many.pad
Result
{data 'n'}
[1,2,3,4,5,6]
{/data}
{n rows=2, page=3}
{$n},
{/n}


App: regression/framework - Page: tags/a_pager_after_a_cached_paged_tag_pages_its_rows
PHP
tags/a_pager_after_a_cached_paged_tag_pages_its_rows.php
HTML
tags/a_pager_after_a_cached_paged_tag_pages_its_rows.pad
Result
<?php

// The two paged tags are one entry of the option form: the second is a hit, which runs
// no handling of its own rows. vary= keeps a run off an earlier run's copy.

$items = [ [ 'n' => 1 ], [ 'n' => 2 ], [ 'n' => 3 ], [ 'n' => 4 ], [ 'n' => 5 ] ];
$token = uniqid ( '', TRUE );

?>
{items page=2, rows=2, cache=60, vary=$token}{$n} {/items}|{items page=2, rows=2, cache=60, vary=$token}{$n} {/items}|{pager 'items'}{$kind}:{$page} {/pager}


App: regression/framework - Page: tags/pager_as_a_pair_hands_the_links_over_as_rows
PHP
tags/pager_as_a_pair_hands_the_links_over_as_rows.php
HTML
tags/pager_as_a_pair_hands_the_links_over_as_rows.pad
Result
<?php

$products
= range ( 1, 100 );
$pg = 6;

$_GET ["q"] = "red shoe";

?>
{products page=$pg, rows=10}{/products}{pager 'products', window=1}[{$kind} {$page} {$label}]{/pager}


App: regression/framework - Page: tags/pager_counts_the_rows_the_options_before_the_page_left
PHP
tags/pager_counts_the_rows_the_options_before_the_page_left.php
HTML
tags/pager_counts_the_rows_the_options_before_the_page_left.pad
Result
<?php

$products
= range ( 1, 100 );
$pg = 6;

$_GET ["q"] = "red shoe";

?>
{products where='$products gt 70', page=2, rows=10}{/products}{pager}[{$kind} {$page}]{/pager}|{products page=2, rows=10, where='$products gt 95'}{$products} {/products}{pager window=0}[{$page}]{/pager}|{pager query='p'}{last@pager}{$href}{/last@pager}{/pager}


App: regression/framework - Page: tags/pager_links_the_pages_around_the_current_one_keeping_the_query
PHP
tags/pager_links_the_pages_around_the_current_one_keeping_the_query.php
HTML
tags/pager_links_the_pages_around_the_current_one_keeping_the_query.pad
Result
<?php

$products
= range ( 1, 100 );
$pg = 6;

$_GET ["q"] = "red shoe";

?>
{products page=$pg, rows=5}{/products}{pager 'products', window=2}


App: regression/framework - Page: tags/pager_of_a_single_page_renders_nothing_and_a_pair_its_else
PHP
tags/pager_of_a_single_page_renders_nothing_and_a_pair_its_else.php
HTML
tags/pager_of_a_single_page_renders_nothing_and_a_pair_its_else.pad
Result
<?php

$products
= range ( 1, 100 );
$pg = 6;

$_GET ["q"] = "red shoe";

?>
[{products where='$products le 4', page=1, rows=5}{/products}{pager 'products'}]{pager 'products'}{$label}@else@one page{/pager}


App: regression/pages - Page: select/demo/a_pager_counts_a_select_with_a_join
PHP
select/demo/a_pager_counts_a_select_with_a_join.php
HTML
select/demo/a_pager_counts_a_select_with_a_join.pad
Result
<?php

// A pager after a select that joins two tables sharing a column name - orders and
// customers, both with customerNumber - counts its rows: the count ran the select list
// as a derived table, which MySQL refuses with two columns of one name ("1060: Duplicate
// column name 'customerNumber'"), and the page ended at the pager.

$padSelect ['ordersPaged'] = [ 'db' => 'orders', 'key' => 'orderNumber' ];

?>
[{ordersPaged join='customers on customers.customerNumber = orders.customerNumber', where="customers.country = 'Norway'", order='orderNumber', page=1, rows=3}{$orderNumber} {$customerName}; {/ordersPaged}]
{pager 'ordersPaged', window=0}{$kind}:{$page} {/pager}


App: regression/pages - Page: select/demo/a_pager_counts_the_rows_its_fields_make
PHP
select/demo/a_pager_counts_the_rows_its_fields_make.php
HTML
select/demo/a_pager_counts_the_rows_its_fields_make.pad
Result
<?php

// A pager counts the rows the select answers also when its fields= decides what a row is:
// distinct countries, or one row of totals. The count over the table alone was taken
// whenever distinct=, group=, having= and union= were not given, so 27 countries had the
// 13 pages of the 122 customers, and the one row of totals a pager of 28 pages.

$padSelect ['countriesPaged'] = [ 'db' => 'customers', 'key' => 'customerNumber' ];
$padSelect ['paymentTotals'] = [ 'db' => 'payments', 'key' => 'checkNumber' ];

?>
[{countriesPaged fields='distinct country', order='country', page=1, rows=10}{$country}; {/countriesPaged}]
({pager 'countriesPaged', window=0}{$kind}:{$page} {/pager})
[{paymentTotals fields='count(*) as n', page=1, rows=10}{$n}{/paymentTotals}]
({pager 'paymentTotals', window=0}{$kind}:{$page} {/pager})