Forum

Thread tagged as: Problem, Runway

Template includes causing problems with perch blocks UI in runway 3.1.2

Not sure if this is related my last post - https://forum.grabaperch.com/forum/09-27-2018-using-page-attributes-as-template-include-in-perch-collection-not-working

Template fields are not displaying in the UI when a new block item is added from a template include inside a collection template.

I have a runway collection template some of which is comprised of a set of blocks in a sub-template (_content_blocks.html) - this is also used in other standard page templates as a template include and causes no problem with the UI in that case.

Each block is itself a template include, i.e. _content_blocks.html:

<perch:block label="Photo" type="image" icon="photo">
     <perch:template path="content/default/blocks/_image.html" rescope="parent"  />
</perch:block>

When I try to add the above block item in Perch admin (Runway 3.1.2), only the block title bar (showing block type rather than label) and the block-add-bar appear in the UI but none of the template fields in _image.html appear.

If I save changes after adding the block, the fields appear fine, and if I copy the contents of the _image.html into the parent template (_content_blocks.html), the fields appear, although the block title bar displays the block type rather than the block label.

This problem doesn't occur when the same _content_blocks.html is used as a template include by another template assigned to a content region - the new blocks display when added and the block title bar displays the block label as you would expect.

Seems like there's a problem instantiating blocks... as template includes.. inside in collections! Anyone else experience similar unpredictable behaviour?

Adam Green

Adam Green 0 points

  • 2 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

As a quick test, have you tried updating your template syntax? (Just thinking about the elements that might have changes with the update)

<perch:block label="Photo" type="image" icon="photo"> 
    <perch:template path="content/default/blocks/_image.html" rescope="parent"> 
</perch:block>

Sorry, updating the template syntax to the above makes no difference, although there are plenty of other self-closing tags in all the other blocks int the same file.

Just posted diagnostics in other thread: https://forum.grabaperch.com/forum/09-27-2018-using-page-attributes-as-template-include-in-perch-collection-not-working.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Adam,

Seems like there's a problem instantiating blocks... as template includes.. inside in collections! Anyone else experience similar unpredictable behaviour?

I use template includes inside blocks and I don't see the issue you are describing. I'm also on Runway 3.1.2

Thanks Hussein. Are your blocks and template includes in a collection template? This is where I’m seeing the problem. Same blocks and same includes in a standard template assigned to a content region works fine.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

I don't use it in a Collection, but I tested it and I still don't see the issue. Can you post your full template?

Thanks again Hussein - I could post the full template but you would't thank me as includes are nested within includes so there'd be a lot to post... & it seems that the depth of nesting is where the problem lies.

The final include which contains the block content was removed from the main template by 3 levels, i.e. walks.html > _listing_common.html > _content_blocks.html > _image.html

Moving the _content_blocks.html up the chain of includes has resolved the issue & block fields are now displaying as expected when I add a new content blocks. It's now structured like this: walks.html > _content_blocks.html > _image.html It seems that 2 levels of includes work fine but 3 levels trips up perch blocks UI?

Now I know the cause of the problem I see others have had problems with nested templates, though there's no mention of any nesting limitation in the docs on template includes: - https://docs.grabaperch.com/perch/content/templates/template-includes/ - https://docs.grabaperch.com/templates/includes/

And there was I happily nesting away, disappearing up my own backside without any problems 'til this strange UI bug appeared!

Drew McLellan

Drew McLellan 2638 points
Perch Support

You can't currently nest includes inside includes.

Thanks Drew - my bad! Same cause for other recent issues experienced here: https://forum.grabaperch.com/forum/09-27-2018-using-page-attributes-as-template-include-in-perch-collection-not-working

I obviously need to flatten out my template architecture - I've been trying to re-use existing templates rather than duplicating template code all over the place!