-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Closed
Copy link
Description
Short description of the issue
When using the createPage
method in a custom class that extends Page
, the instantiation of the Page
object using $p = new Page();
is not working as expected, even though it should. The issue is that the created page is not visible in the ProcessWire admin interface, although it is stored in the database.
<?php namespace ProcessWire;
class ProductPage extends Page {
public function createPage($array) {
$pages = $this->wire('pages');
$p = new Page();
$p->setOutputFormatting(false);
$p->template = 'my-template'; // valid template
$p->parent = $pages->get('/foo/'); // parent exists, template family allows 'my-template'
$p->name = 'bar';
$p->title = 'bar';
$p->save();
}
}
Expected behavior
The createPage method should successfully create a new page with the specified template, parent, name, and title, and it should be visible in the ProcessWire admin interface.
Actual behavior
- The created page is not visible in the ProcessWire admin interface, even though it is stored in the database.
- The code works when executed from '/site/templates/my-template.php' (a page is created).
Optional: Screenshots/Links that demonstrate the issue
N/A
Optional: Suggestion for a possible fix
Your possible fix goes here.
Steps to reproduce the issue
- Create a custom class that extends Page with a createPage method, similar to the code provided in the issue description.
- Instantiate the custom class and call the createPage method.
- Check the ProcessWire admin interface to see that the created page is not visible.
Setup/Environment
- ProcessWire version: 3.0.229
- PHP version: 8.2
- MySQL version: 10.6.13-MariaDB
- 3rd party modules: TracyDebugger, ProcessWireUpgrade, ProcessDatabaseBackups, ImportPagesCSV
Metadata
Metadata
Assignees
Labels
No labels