GeniXCMS

Posts Class

categoryAPI edit_calendar31 Mar 2026

Core Content (Posts & Pages) Class


The Posts class is the primary engine for content management in GeniXCMS. It provides a comprehensive interface for creating, modifying, and retrieving all editorial content types, including blog posts, static pages, and custom module-driven content.


⚡ Data Persistence & CRUD

Posts::insert(array $vars)

Dispatches a new content record to the database.

  • Automation: It automatically generates a unique, SEO-friendly slug based on the title and handles the creation of a revision history.
  • Payload: Requires keys like title, content, author, type, and status.
$vars = [
    'title'   => 'The Future of GeniXCMS',
    'cat'     => 5,
    'content' => 'Full editorial content here...',
    'author'  => 'admin',
    'type'    => 'post',
    'status'  => '1'
];
Posts::insert($vars);

Posts::update(array $vars)

Modifies an existing record. The method automatically detects the ID and applies changes to the provided keys only.


🌎 Content Retrieval & Filtering

Posts::recent(array $config)

Retrieves a filtered collection of recent content.

$config = [
    'num'  => 5,      // Number of records
    'type' => 'post', // 'post' or 'page'
    'cat'  => 1       // Filter by category ID
];
$collection = Posts::recent($config);

📝 Format & Rendering Engine

These methods handle the transformation of raw database content into presentation-ready HTML.

Method Role Logic
content($raw) Rendering Block Cleans content, processes Shortcodes, and handles the [[--readmore--]] tag.
format($raw, $id) Archive Snippet Truncates content at the "Read More" tag and appends a permalinked "Read More" button.
title($id) Identity Resolves the plain-text title for a specific record.

🖼️ Visual Asset Management

Posts::getPostImage(int $id)

Retrieves the featured image path associated with the record through its metadata.

Posts::getImage(string $content, int $n = 1)

An intelligent parser that scans the content body and extracts the URL of the Nth image found. This is frequently used for automated thumbnail generation from content.


🏷️ Metadata Management (Post Parameters)

The Posts class provides a robust PostParam system for handling custom fields and metadata.

  • addParam($key, $val, $id): Commits a new metadata key-value pair.
  • editParam($key, $val, $id): Updates existing metadata.
  • getParam($key, $id): Retrieves a specific metadata value.
  • delParam($key, $id): Permanent removal of a specific key.
  • Form Automation: When creating an input in the post or page form, use the naming convention name="param[key_name]" to have it automatically processed and saved by the controller.
// Example: Getting a custom SEO title from metadata
$seo_title = Posts::getParam('seo_title', $post_id);

lightbulb
TipRead More Support: To create an "Excerpt" in your content manager, simply insert [[--readmore--]] into your HTML. The Posts::format() method will then ensure your archive pages display a clean summary instead of the full article.

See Also

  • Pages Class — Helper methods to detect current content context.
  • Params Class — Registering custom fields that map to the PostParam system.
  • User Guide: Posts — Managing editorial content from the dashboard.