[SOLVED]Problem with selecting page layout


(Manuel Heusel) #1

Hello there,

I updated Neos to the newest Version and everything works fine, beside of the page layout.
I changed everything like described (changed the Prototypes in the root.fusion and so on), but only the layout selection don’t work.

I made it similar to the Neos.Demo but still nothing changed. There’s no exception, nothing.

So I don’t know what to do now, so I hope anyone here can help me.

Thank you


(Bastian Waidelich) #2

Can you share the Fusion code that you use to switch the layout?


(Manuel Heusel) #3

Sure.

prototype(Vendor.Test:DefaultPage) < prototype(Neos.Neos:Page){
 //the normal stuff in here
}

and underneath that
page = Neos.Neos:Page

default < page

landingPage < page
landingPage.body {
	landingPage = ${true}
	templatePath = 'resource://Vendor.Test/Private/Templates/Page/LandingPage.html'
}

I tried it with another Prototype (like in the Demo)

prototype(Neos.NodeTypes:Page) < prototype(Neos.Neos:Page) 

but nothing changes. Maybe I’m so focused on it that I can’t see the mistake


(Bastian Heist) #4

@bladegh are you using Neos.NodeTypes? The “layout” root matcher was moved from Neos.Neos to Neos.NodeTypes with 4.0. See this link in the change logs:
http://neos.readthedocs.io/en/stable/Appendixes/ChangeLogs/400.html#id52

If you’re not using Neos.NodeTypes, the following Fusion code might fix your bug:

root.layout {
  @position = 'end 9997'
  layout = ${q(node).property('layout') != null && q(node).property('layout') != '' ? q(node).property('layout') : q(node).parents('[subpageLayout][subpageLayout != ""]').first().property('subpageLayout')}
  condition = ${this.layout != null && this.layout != ''}
  renderPath = ${'/' + this.layout}
}

This will make it work as before. However, we recommend not to use “renderPath” - instead, you should rely on prototype-based rendering (basically use “type” instead of “renderPath”) as documented here.


(Manuel Heusel) #5

Yes, I’m using NodeTypes.
Ah okay I didn’t saw that, thank you.
What does this exactly mean for me?
I have to move the selection from Neos.Neos to Neos.NodeTypes and what else?


(David Sporer) #6

Maybe this is not the problem here but I had a problem because I was still using .ts2 as file extension for the Fusion files. After I changed that to .fusion it worked again :slight_smile:


(Manuel Heusel) #7

I’m already using the .fusion file extension, so that’s not the problem here, but thank you


(Bastian Heist) #8

Hey @bladegh
If you’re using Neos.NodeTypes, then this refactoring should not be the reason for the behavior you’re experiencing. Therefore you don’t need to change anything (at least not because of this change). Let’s look at your Layout switching code again:

default < page

landingPage < page
landingPage.body {
	landingPage = ${true}
	templatePath = 'resource://Vendor.Test/Private/Templates/Page/LandingPage.html'
}

Two questions here:

  • What does landingPage = ${true} do ?
  • Where do you actually switch the layout? You should have something like this somewhere in your code?
root.landingPage {
  condition = ${q(node).is('[instanceof Your.Site:LandingPage]')}
  renderPath = 'landingPage'
}

(Hint: While this works, it’s the old, discouraged way of switching the page template - see here for the current best practice.)


(Manuel Heusel) #9

Sorry for the long answer time.

The landingPage = ${true} was only for testing.

I finally made it with the Neos.Fusion:Case

root = Neos.Fusion:Case {
  documentType {
    condition = Neos.Fusion:CanRender {
      type = ${q(documentNode).property('_nodeType.landingpage')}
    }
    type = ${q(documentNode).property('_nodeType.default')}
  }

}

Thank you all for your help :slight_smile: