-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contao 5.3 - introduce support for nested elements #51
Comments
I guess this is caused by |
Yeah, this extension is not compatible with nested elements at the moment. Simple as that. I'll tag this as a feature because we'll have to introduce support for them, in whichever way we'll do that. |
This fix worked for me. main...dennisbohn:contao-node:main The ContentListener.php class contains an additional method to iterate through content elements. private function findNodeIdByContentId($contentId): int
{
$pid = $contentId;
$ptable = 'tl_content';
// Recursive node id finder
while ($ptable === 'tl_content') {
list($pid, $ptable) = $this->db->fetchNumeric('SELECT pid, ptable FROM tl_content WHERE id=?', [$pid]);
}
return $pid;
} The onLoadCallback method has been changed to the new method. public function onLoadCallback(DataContainer $dc): void
{
switch (Input::get('act')) {
case 'edit':
case 'delete':
case 'show':
case 'copy':
case 'copyAll':
case 'cut':
case 'cutAll':
$nodeId = $this->findNodeIdByContentId($dc->id);
break;
case 'paste':
if ('create' === Input::get('mode')) {
$nodeId = $dc->id;
} else {
$nodeId = $this->findNodeIdByContentId($dc->id);
}
break;
case 'create':
// Nested element
if (Input::get('ptable') === 'tl_content') {
$nodeId = $this->findNodeIdByContentId(Input::get('pid'));
} else {
$nodeId = $dc->id;
}
break;
default:
// Ajax requests such as toggle
if (Input::get('field') && ($id = Input::get('cid') ?: Input::get('id'))) {
$nodeId = $this->findNodeIdByContentId($id);
// Nested element
} else if (Input::get('ptable') === 'tl_content') {
$nodeId = $this->findNodeIdByContentId($dc->id);
} else {
$nodeId = $dc->id;
}
break;
}
$type = $this->db->fetchOne('SELECT type FROM tl_node WHERE id=?', [$nodeId]);
// Throw an exception if the node is not present or is of a folder type
if (!$type || NodeModel::TYPE_FOLDER === $type) {
throw new AccessDeniedException('Node of folder type cannot have content elements');
}
$this->checkPermissions((int) $nodeId);
} Create, copy, edit, delete, moving, info and toggle works fine inside and outside the element group. Nested element groups are also possible. But it feels that it needs some more testing. I'm not sure what all needs to be taken into account when it comes to ajax requests. |
When an element group is included in a node and I want to edit the child elements, I currently get an error message.
If I comment out lines 71 - 73 in the "ContentListener.php", I can edit the entries.
contao-node/src/EventListener/ContentListener.php
Lines 71 to 73 in 842fc32
The text was updated successfully, but these errors were encountered: