How to integrate my snippet with getPage

Hi. I wrote my snippet and named it usergenDisplaySnippet. Displays the contents of the table, but does not split it into pages.

   [[!getPage?
        &element=`usergenDisplaySnippet`
        &limit=`5`
        &tpl=`usergenRowTpl`
        &pageVarKey=`page`
        &totalVar=`total`
    ]]

here usergenDisplaySnippet:

<?php
$userid = $modx->user->get('id');

if (!$userid) {
    return "error autorization";
}


$sql = "SELECT chr, pos, rsid, ref, alt FROM usergen WHERE userid = :userid";
$stmt = $modx->prepare($sql);
$stmt->bindValue(':userid', $userid, PDO::PARAM_INT);
$stmt->execute();
$userData = $stmt->fetchAll(PDO::FETCH_ASSOC);

if ($userData) {
    $output = '<h3>Данные из таблицы usergen:</h3>';
    $output .= '<table border="1">
                <thead>
                    <tr>
                        <th>CHR</th>
                        <th>POS</th>
                        <th>RSID</th>
                        <th>REF</th>
                        <th>ALT</th>
                    </tr>
                </thead>
                <tbody>';
    
  
    foreach ($userData as $row) {
        $output .= '<tr>';
        $output .= '<td>' . htmlspecialchars($row['chr']) . '</td>';
        $output .= '<td>' . htmlspecialchars($row['pos']) . '</td>';
        $output .= '<td>' . htmlspecialchars($row['rsid']) . '</td>';
        $output .= '<td>' . htmlspecialchars($row['ref']) . '</td>';
        $output .= '<td>' . htmlspecialchars($row['alt']) . '</td>';
        $output .= '</tr>';
    }
    
    $output .= '</tbody></table>';
} else {
    $output = '<p>No data</p>';
}

return $output;

For your snippet to work correctly with getPage, you have to read the properties limit and offset in the snippet and only return the requested part of the data. And you also have to set a placeholder for the total amount of available items.

For more information see this article: