Function: neos:rendering.inEditMode()

Hello Community!

In past (with Neos 4.0), i was using the method:

Description: https://neos.readthedocs.io/en/stable/References/ViewHelpers/Neos.html#neos-rendering-ineditmode

<f:if condition="{neos:rendering.inEditMode()}"></f:if>

(from Neos\Neos\ViewHelpers)

if i wanted to distinguish the rending in backend and in frontend. For example i’ve wrote a NodeType for which i deactivated the setting of the URL in the backend. So that you can not accidentially click on the URL and navigate away from the backend. In frontend the URL got rendered fine.

But since we are now on Neos 5.1.5, this method seems not to work anymore and all my URLs are equally rendered in backend and in frontend, like without any clickable link :sweat_smile:

Is there a new method/renamed method or is it maybe deprecated?

Thank you! :slight_smile:

Hi Benjamin,

I just gave it a try and the Rendering.InEditMode ViewHelper works for me with Neos 5.2 just like before:

Root.fusion:

root >
root = Neos.Fusion:Template {
    templatePath = 'resource://Neos.Demo/Private/Templates/Test.html'
}

And The Test.html template:

{namespace neos=Neos\Neos\ViewHelpers}
<f:if condition="{neos:rendering.inEditMode()}" then="BACKEND" else="FRONTEND" />

I get “BACKEND” in Backend and “FRONTEND” in the frontend.

Are you sure that you are really editing a template that is used? Using Fluid is discouraged in favor of Fusion templates and with 5+ some of the base templates were replaced.

With Fusion you could achieve a similar behavior with node.context.inBackend, for example:

root = Neos.Fusion:Case {
    backend {
        condition = ${node.context.inBackend}
        renderer = 'BACKEND'
    }
    default {
        condition = true
        renderer = 'FRONTEND'
    }
}

Hey Bastian,

that is really interesting. It is actually working with the same SitePackage in my local neos installation on docker (Neos 4.2.0)

I think the mistake is at another place.

We also have a condition after the inEditMode() function:

<f:if condition="{neos:rendering.inEditMode()}">
  <f:then>
<f:if condition="{teaserShape} == 'teaserWithImage'">
<html></html>
</f:if>
</f:if>

In my local dev in neos 4.2.0 the condition regarding teaserShape is set as the following:

teaserShape:
  type: string
  defaultValue: 'teaserWithImage'
  ui:
    label: 'i18n'
    reloadIfChanged: true
    inspector:
      group: 'dTeaser'
      editor: 'Neos.Neos/Inspector/Editors/SelectBoxEditor'
      editorOptions:
        allowEmpty: FALSE
        placeholder: 'Default'
        values:
          '':
            label: ''
          teaserWithImage:
            label: 'i18n'
            icon: 'icon-images'
          textOnlyTeaser:
            label: 'i18n'

Somehow it seems not to work in our integration environment, since the translation of this module is not even fetched.

Instead of (from local dev):

image

We get some cryptographic nodetype paths which can not be correct. That might be the issue. I will set it to solved when i do know more about it.

Thank you! :slight_smile:

1 Like

Any news on this one?

Hey @bwaidelich, the mistake was indeed not the other condition that was questioned.

Instead and to solve it we had to switch from {neos:rendering.inEditMode()} to {node.context.inBackend}

Thank you! :slight_smile:

1 Like