Skip to content

Commit

Permalink
Fixed missing container type
Browse files Browse the repository at this point in the history
  • Loading branch information
luke- committed Feb 3, 2025
1 parent 5fc6b39 commit 97d492d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/template/elements/BaseElementVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function render(bool $editMode = false): string
'default' => $this->elementContent->isDefault(),
], $this->options);

$options['template_instance_type'] = TemplateInstance::getTypeById($options['template_instance_id']);
$options['template_instance_type'] = $this->elementContent->templateInstance?->getType();

// We only need the template_id for container content elements
if ($this->elementContent instanceof ContainerElement) {
Expand Down
16 changes: 8 additions & 8 deletions modules/template/models/TemplateInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
*/
class TemplateInstance extends ActiveRecord
{

const TYPE_PAGE = 'page';
const TYPE_CONTAINER = 'container';


/**
* @inheritdoc
*/
Expand Down Expand Up @@ -146,13 +151,8 @@ public function getRoot(): ?self
return self::findOne(['page_id' => $this->page_id, 'container_item_id' => null]);
}

public static function getTypeById($id): string
{
$instance = self::findOne($id);
if ($instance === null) {
return '';
}

return $instance->container_item_id === null ? 'page' : 'container';
public function getType() {
return $this->container_item_id === null ? self::TYPE_PAGE : self::TYPE_CONTAINER;
}

}

0 comments on commit 97d492d

Please sign in to comment.