Skip to content

Commit

Permalink
feat: add title field to migrated pageclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Mar 20, 2023
1 parent 65174b8 commit c5bd95a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2619,7 +2619,10 @@ public function migratePageClasses($path, $namespace = 'ProcessWire', $tags = ''
try {
$templatename = $tmp::tpl;
$tpl = $this->wire->templates->get($templatename);
if (!$tpl) $tpl = $this->createTemplate($templatename, $class);
if (!$tpl) {
$tpl = $this->createTemplate($templatename, $class);
$this->addFieldToTemplate("title", $tpl);
}
if ($tags) $this->setTemplateData($templatename, ['tags' => $tags]);
$tmp->template = $tpl;
} catch (\Throwable $th) {
Expand Down Expand Up @@ -2850,6 +2853,8 @@ public function refresh()
/**
* Remove Field from Template
*
* Will silently return if field has already been removed
*
* @param Field|string $field
* @param Template|string $template
* @param bool $force
Expand All @@ -2866,6 +2871,7 @@ public function removeFieldFromTemplate($field, $template, $force = false)
/** @var Fieldgroup $fg */
if ($force) $field->flags = 0;

// if field is already removed we exit silently
if (!$fg->get($field->name)) return;

$fg->remove($field);
Expand Down

0 comments on commit c5bd95a

Please sign in to comment.