Hello everyone!  We've just released Backdrop 1.11, and would love your feedback!  A summary of new features can be found in our blog.

Most helpful answers

I started with a page template in a theme directory, the way I did it in D7...

That's a good start, but you'd need to rename the template file. (The file named page.tpl.php in Backdrop is the same as the file named html.tpl.php in Drupal 7)

On the forum i was told to create template in layout directory instead

That's almost right, you'd need to create an entire layout (including an .info file and maybe CSS) not only the template file. You can copy (or rename) your Drupal 7 page.tpl.php file for the layout template file (layout--NAME.tpl.php) if you want it to be nearly identical. You'd then need to remove the header, footer, menu, and anything else you'd like to replace with a block in Backdrop.

 I have a feeling that things work the other way round compared to last time. 

No, it works the same now in 1.11 as id did before.

Does it mean I can remove layout files altogether and just keep coding template in the theme directory?

Yes! I do this quite frequently.  You'll first need to find out which layout is most similar to what your Drupal 7 theme did for it's layout. Then you can override that Layout template file in your theme instead of creating an entirely new layout. 

For example, if your Drupal 7 site had a left sidebar, you could use the Moscone layout in Backdrop. Then you would copy the layout--moscone.tpl.php file (from core/layouts/moscone/) into your theme. Then you could copy what you wanted to keep from your Drupal 7 page.tpl.php file into that layout--moscone.tpl.php file.

You can visit admin/structure/layouts/settings to see all the layouts core provides.

Comments

Did something change regarding precedence of layout and template files?

Three months ago I ditched template file, because consensus was to create layout and start from there.

Now I'm back to work on this site, and it seems to work the other way round - I can remove layout file and site works fine. OTOH template must be up to date...

I have upgraded to 1.11 some time ago (two weeks maybe), but noticed this today.

drop's picture

Hi @akarso, and thanks for the question.

I'm afraid I don't understand what you're asking.

Layouts have template files, just like other parts of the page like blocks, nodes, and views.  Precedence for layout template files goes as follows: The layout--NAME.tpl.php file in the layout directory is the default template (similar to how the templates located in a module's directory are default templates). Default templates can be overridden by a layout--NAME.tpl.php file in your base-theme, or theme. Layout template files behave the same way as template files for other parts of Backdrop, and this has not changed since Backdrop 1.0.0.

I can remove layout file and site works fine

Do you know if your site is using the Layout that maps to the file(s) you removed? It sounds likely that it is not. Perhaps your site is using one of the core layouts provided instead.

Well, it's likely, that I still can't get this right, then.

I started with a page template in a theme directory, the way I did it in D7. Wanted it to be as simple as possible, but couldn't quite get it to work right.

On the forum i was told to create template in layout directory instead, so I did, and was able to place blocks I created where I wanted.

Now I'm back to work after a pause and I have a feeling that things work the other way round compared to last time. 

Default templates can be overridden by a layout--NAME.tpl.php file in your base-theme, or theme.

Does it mean I can remove layout files altogether and just keep coding template in the theme directory?

drop's picture

I started with a page template in a theme directory, the way I did it in D7...

That's a good start, but you'd need to rename the template file. (The file named page.tpl.php in Backdrop is the same as the file named html.tpl.php in Drupal 7)

On the forum i was told to create template in layout directory instead

That's almost right, you'd need to create an entire layout (including an .info file and maybe CSS) not only the template file. You can copy (or rename) your Drupal 7 page.tpl.php file for the layout template file (layout--NAME.tpl.php) if you want it to be nearly identical. You'd then need to remove the header, footer, menu, and anything else you'd like to replace with a block in Backdrop.

 I have a feeling that things work the other way round compared to last time. 

No, it works the same now in 1.11 as id did before.

Does it mean I can remove layout files altogether and just keep coding template in the theme directory?

Yes! I do this quite frequently.  You'll first need to find out which layout is most similar to what your Drupal 7 theme did for it's layout. Then you can override that Layout template file in your theme instead of creating an entirely new layout. 

For example, if your Drupal 7 site had a left sidebar, you could use the Moscone layout in Backdrop. Then you would copy the layout--moscone.tpl.php file (from core/layouts/moscone/) into your theme. Then you could copy what you wanted to keep from your Drupal 7 page.tpl.php file into that layout--moscone.tpl.php file.

You can visit admin/structure/layouts/settings to see all the layouts core provides.