backdrop-contrib / paragraphs

Paragraphs module to control your content flow
https://backdropcms.org/project/paragraphs
GNU General Public License v2.0
5 stars 11 forks source link

Scratch Paragraphs in node->field_paragraph after latest update #105

Closed neessen closed 2 years ago

neessen commented 2 years ago

Hey

I just updated the paragraphs module to 1.x-1.2.0-alpha1 which gave me an issue. The node->field_paragraphs field now has a paragraph with the value "scratch_paragraph". What is the reason for this? It gives me some issues because I can no longer check if $node->field_paragraph['und'] is empty or $node->field_paragraph['und'][0] isset.
These are now returning true because of this new scratch_paragraph even though I have not created any paragraphs on the node, and that results in some un-wanted markup based on my if-statement. That is why I am pretty curious to why it exists after the latest update, and if that is the intended behaviour?

Dump of my empty paragraph field:

Array
(
    [und] => Array
        (
            [0] => Array
                (
                    [value] => scratch_paragraph
                )

        )

)
laryn commented 2 years ago

@neessen Thank you for testing the alpha1 release! The scratch_paragraph value was added as a part of https://github.com/backdrop-contrib/paragraphs/issues/60 which adds new functionality, and the purpose is to "[add] a dummy value to the paragraphs field to make rendering possible". (See below for more on that new functionality if you haven't seen that yet).

Much of the meat of the changes came from patches setting in the D7 queue. The one that introduced this is here:

Here's an example of checking whether it's an empty paragraphs field in the new code that came in:

      // If we are dealing with an empty paragraphs field, render an insert point.
      if ($items[0]['value'] == 'scratch_paragraph') {

What are your thoughts on this? Does it introduce too large of an issue for your use case, or is it surmountable?

Here's a video showing some of the new functionality that is added in (front end modal administration; ability to un/publish paragraphs) in the alpha1 release:

neessen commented 2 years ago

Hey Laryn

Nice feature with the Edit modal - I will look into that :)

So just to understand this correctly; The scratch paragraph is only present if no other paragraph is added to the node, is that correct?

laryn commented 2 years ago

:+1:

laryn commented 2 years ago

@neessen Please reopen if you find an issue or things aren't as described.