Creates and manages ProcessWire custom page classes that extend Page with template-specific methods, properties, and logic. Covers naming conventions, get() overrides, API access patterns, inheritance, traits, and common pitfalls. Use when creating or editing custom page classes, adding template-specific methods to pages, or working with typed pages in ProcessWire.
Custom page classes let you extend ProcessWire's Page with template-specific methods and properties. Every page using a given template becomes an instance of your custom class.
/site/config.php:$config->usePageClasses = true;
/site/classes/ matching the template name:| Template | Class | File |
|----------|-------|------|
| home | HomePage | HomePage.php |
| blog-post | BlogPostPage | BlogPostPage.php |
| basic-page | BasicPagePage | BasicPagePage.php |
Rule: PascalCase the template name + append Page.
<?php namespace ProcessWire;
class HomePage extends Page {}
get()public function get($key) {
if($key === 'authorName') return $this->getAuthorName();
return parent::get($key);
}
This makes $page->authorName work as a virtual property.
// Correct — always use wire()
$this->wire()->pages->find('template=blog-post');
$this->wire()->sanitizer->text($value);
// Works but NOT preferred — not multi-instance safe
$this->pages;
pages()->find('template=product');
Inside the class, $this->property accesses the property directly, bypassing the get() method's lazy loading. For example, $this->template may return null, while $page->template (external) returns a Template object. Use $this->get('property') for consistent behavior.
npx skills add gebeer/processwire-page-classes下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer