PHP code example of pubvana / pages
1. Go to this page and download the library: Download pubvana/pages library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pubvana / pages example snippets
'plugins' => [
'pubvana/pages' => [
'enabled' => true,
'priority' => 43,
],
],
$pages = Flight::pages();
// Create a page
$page = $pages->create([
'title' => 'About Us',
'slug' => 'about-us',
'content' => '<p>Welcome.</p>',
'status' => 'published',
'meta_title' => 'About Us',
'meta_description' => 'Learn more about us.',
], $userId);
// Update a page
$pages->update($id, [
'title' => 'About Us - Updated',
'content' => '<p>New content.</p>',
'status' => 'published',
], $userId);
// Bypass HTML sanitization for a single save
$pages->create([
'content' => '<p>Trusted HTML</p>',
'purify_content' => false,
// ...
], $userId);
// Find by ID or slug
$page = $pages->find(5);
$page = $pages->findBySlug('about-us');
// List with pagination
$result = $pages->list(page: 1, perPage: 25);
// $result = ['items' => [...], 'total' => 12, 'page' => 1, 'per_page' => 25]
// Soft-delete (system pages are protected)
$pages->delete($id);
// Version history
$versions = $pages->getVersions($id);
$pages->restoreVersion($pageId, $versionId, $userId);
// Record a page view (referrer domain is optional, typically parsed from HTTP_REFERER)
$referrer = parse_url($_SERVER['HTTP_REFERER'] ?? '', PHP_URL_HOST) ?: null;
$pages->recordView($pageId, $referrer);
$count = $pages->getViewCount($pageId);