terminal42 / contao-node

Manage content centrally as nodes and reuse them everywhere.
MIT License
29 stars 8 forks source link

wrapper for nodes #21

Closed plandolt closed 4 years ago

plandolt commented 4 years ago

I was in need to have a wrapper div on the node level containing all content elements within the node. This way I am able to define id/class to the node for styling. Then I can include this node anywhere and have it styled without any further configuration (like doing the wrapper when including the node). I hope you get the idea behind :)

Toflar commented 4 years ago

Thanks for contributing! Haven't we introduced wrappers already in https://github.com/terminal42/contao-node/issues/13? What's different here? :)

plandolt commented 4 years ago

The implementation in #13 does the same but you need to do that everywhere you include nodes. This is not practicable when including a node on several pages where you need to have a wrapper with a consistent class. This PR implements a wrapper configuration on the node level to encapsulate the content elements within the node definition.

Toflar commented 4 years ago

I see. Implementation-wise I would also like to have that template based, so that's one thing to adjust for sure. But conceptual-wise this sounds okay to me. Wdyt @qzminski?

plandolt commented 4 years ago

I see your point. But I might need a little kickstart info to how I should implement a template based info.

qzminski commented 4 years ago

I would also like to see an extra field in the wrapper subpalette where you can select a partial frontend template (e.g. node_default.html5) used to render that wrapper. So if wrapper is enabled, the $buffer in generateBuffer() method should become:

if ($nodeModel->wrapper) {
    $template = new FrontendTemplate($nodeModel->template);
    $template->setData($nodeModel->row());
    $template->buffer = $buffer;

    $buffer = $template->parse(); // to be returned
}
plandolt commented 4 years ago

voilà 😀

qzminski commented 4 years ago

Look pretty okay to me, @Toflar ?

qzminski commented 4 years ago

1.2.0 released, thank you @scuben !