Content Pagination Class
The Paging class is a specialized utility in GeniXCMS designed to build structural pagination links for both the frontend content archives and the administrative management tables. It handles complex record counting, page calculation, and Bootstrap-compliant HTML generation in a single method call.
⚡ Core Pagination Method
Paging::create(array $vars, bool $smart_url = false)
Generates a complete, semantic HTML pagination fragment based on the provided configuration.
| Parameter |
Type |
Default |
Description |
$vars |
array |
Required |
Associative configuration for record count and URL patterns. |
$smart_url |
bool |
false |
If true, it generates SEO-friendly URL segments (e.g., /paging/2/). |
Returns: string (HTML fragment).
⚙️ Configuration Schema ($vars)
| Key |
Example |
Description |
table |
'posts' |
Target database table to calculate total record volume. |
where |
'status=1' |
Optional SQL WHERE clause for granular filtering. |
total |
100 |
Optional manual count (overrides automated table query). |
max |
10 |
Maximum items displayed per individual page. |
url |
Site::$url |
Base URL for the pagination assembly. |
paging |
1 |
Current active page integer. |
type |
'number' |
Display style: 'number' (pagination list) or 'pager' (Prev/Next). |
🎨 Implementation Examples
Professional Numbered List (Bootstrap)
Ideal for standard blog archives and administrative data grids.
$vars = [
'table' => 'posts',
'where' => "type='post' AND status='1'",
'max' => 12,
'url' => 'https://site.com/blog/',
'paging'=> 1,
'type' => 'number'
];
echo Paging::create($vars, true);
Simple "Previous/Next" Pager
Ideal for minimalist themes or sequential content flows.
$vars = [
'table' => 'posts',
'max' => 20,
'url' => 'index.php?page=archives',
'paging'=> 1,
'type' => 'pager'
];
echo Paging::create($vars);
🏗️ Technical Workflow
The Paging class operates through several automated phases:
- Metric Calculation: It performs a
Db::num_rows() query on the provided table/where condition to determine the data universe size.
- Logic Partition: Calculates the total page count by dividing the universe size by the
max value.
- URL Assembly: Decodes whether to use standard query parameters (
?paging=X) or SEO-friendly segments (/paging/X/).
- HTML Synthesis: Built-in support for Bootstrap styling, injecting
active and disabled CSS classes to individual page nodes.
lightbulbTipSEO Performance: Always enable the $smart_url = true parameter for public-facing content lists. This ensures search engine crawlers can easily index your deep content archives through clean, predictable URL paths.
See Also
- Router Class — How the system handles the
/paging/ URL segment.
- Db Class — How the Paging engine queries the record volume.