Diseño web Mallorca's picture

Hi Backdropers!

I just installed my first Bac... and coming from D7, must say... this is awsome! all the borring stuff you had to do on each D7 new installations, its out of the box here, so very cool! 

The only thing I'm trying to get is... in D7 you could create page.tpl.php and/or html.tpl.php  and you had a lot of control on your HTML output.

I've seen this layout "thing"... but.. is there any way to make it with the page.tpl.php templates? or html.tpl.php

also I remember in D7, you could do node-id-45.tpl.php and you could theme in HTML the whole page of that node (at least the page render).

also fields could be done. 

 

I've been reading the docs, and see that you can do it with templates but, im creating this templates on my selected theme and cant see that any thing is changing, even with clearing cache. can anyone give me some light in this content?

 

Thanks in advance!

Derek Solutions

 

Accepted answer

Welcome to Backdrop CMS!

For these questions there are much better experts than me and you will probably get a lot more and better advice and also helpful information on the site:

https://docs.backdropcms.org/documentation/developing-themes

But let me tell you how I do it:

page.tpl.php in Backdrop plays a different role than in Drupal, I do not develop themes through page.tpl.php, but by developing my own layout

https://docs.backdropcms.org/documentation/developing-layouts

Layout is what organizes the HTML structure of the site and creates the regions, which can then be formatted through CSS selectors.

node-id-45.tpl.php, as well as custom block templates work the same way and you can use them, but when you get used to working with layouts and custom blocks, these old tools will be superfluous. You do not need to have a special template for node 45 because you can make a layout that manages the design of node 45 much more efficiently. And to manage the design of the field, all you have to do is install the field_wrappers module, which allows you to define a CSS class for the field, but also many more tokens-based capabilities.

Good luck with Backdrop, you won't regret your decision.

Most helpful answers

Let me add one more thing. Layout does not replace the theme, they both work together. When I create a new custom theme, I also make a custom Layout that works with it. Or many Layouts for different parts of the site instead of "node--45.tpl.php" D7 trick.

In order to work with Backdrop, you need to change your work habits a bit. The skills of working with D7 are not canceled, they are only slightly upgraded.

You wrote: in D7 you could create page.tpl.php ... Yes the structuring of the site in D7 is done through page.tpl.php. It's the same in Backdrop, except that the part of the code that is between the opening and closing body tags of page.tpl.php ... is in the file layout --(layout name) .tpl.php

This is pure manual coding of html structure of layout--(name of layout).tpl and has nothing to do with the interface approach to designing through Panels that I also consider messy and never had used after initial test long time ago.

Only switching of layouts is done through the Backdrop interface, they are coded manually not through the interface (as was the case with Panels and Display Suite with D7).

 

 

One additional note: it looks like the correct syntax is "node--45.tpl.php", not "node-id-45.tpl.php".

That template suggestion is created in template_preprocess_node() line 278

$variables['theme_hook_suggestions'][] = 'node__' . $node->nid;

Hi Diseño Web Mallorca. 

I'm not an expert on template overrides, but I've been successful at modifying the page layout by creating new layout templates. See these directions

As far as overriding something like node-id-45.tpl.php - I'm pretty sure you can still do that in Backdrop. Just be sure to place that inside the templates folder in theme folder.

Comments

Hi Diseño Web Mallorca. 

I'm not an expert on template overrides, but I've been successful at modifying the page layout by creating new layout templates. See these directions

As far as overriding something like node-id-45.tpl.php - I'm pretty sure you can still do that in Backdrop. Just be sure to place that inside the templates folder in theme folder.

One additional note: it looks like the correct syntax is "node--45.tpl.php", not "node-id-45.tpl.php".

That template suggestion is created in template_preprocess_node() line 278

$variables['theme_hook_suggestions'][] = 'node__' . $node->nid;

Diseño web Mallorca's picture

Yes, thanks for the tip, I was writting on the top of my head, but it's true that sometimes, this things can make you waste time. 

Welcome to Backdrop CMS!

For these questions there are much better experts than me and you will probably get a lot more and better advice and also helpful information on the site:

https://docs.backdropcms.org/documentation/developing-themes

But let me tell you how I do it:

page.tpl.php in Backdrop plays a different role than in Drupal, I do not develop themes through page.tpl.php, but by developing my own layout

https://docs.backdropcms.org/documentation/developing-layouts

Layout is what organizes the HTML structure of the site and creates the regions, which can then be formatted through CSS selectors.

node-id-45.tpl.php, as well as custom block templates work the same way and you can use them, but when you get used to working with layouts and custom blocks, these old tools will be superfluous. You do not need to have a special template for node 45 because you can make a layout that manages the design of node 45 much more efficiently. And to manage the design of the field, all you have to do is install the field_wrappers module, which allows you to define a CSS class for the field, but also many more tokens-based capabilities.

Good luck with Backdrop, you won't regret your decision.

Diseño web Mallorca's picture

Yes, it seams like the themes now are having less imporatnt on the layout and it's in this core module, i will have to try and get used to it, fot theming I like to user a custom code, not used to doing it by the interface, I think panels on D7 was a really messy module. BUti'm sure I would get used to this. 

has i've seen, now everything resides in "blocks" I wonder if I can create a custom block in theme template, like custom__block.tpl.php and after select this block to appear in the layout. 

Thanks!

Let me add one more thing. Layout does not replace the theme, they both work together. When I create a new custom theme, I also make a custom Layout that works with it. Or many Layouts for different parts of the site instead of "node--45.tpl.php" D7 trick.

In order to work with Backdrop, you need to change your work habits a bit. The skills of working with D7 are not canceled, they are only slightly upgraded.

You wrote: in D7 you could create page.tpl.php ... Yes the structuring of the site in D7 is done through page.tpl.php. It's the same in Backdrop, except that the part of the code that is between the opening and closing body tags of page.tpl.php ... is in the file layout --(layout name) .tpl.php

This is pure manual coding of html structure of layout--(name of layout).tpl and has nothing to do with the interface approach to designing through Panels that I also consider messy and never had used after initial test long time ago.

Only switching of layouts is done through the Backdrop interface, they are coded manually not through the interface (as was the case with Panels and Display Suite with D7).

 

 

Diseño web Mallorca's picture

Thanks! Yes I'm starting to get the concept and sounds good.

I already have the layouts working, added the css, and for the theme scripts I use the add_js in the template.php just That i think that most are scripts in Jquery 3.

 

To be honest it's not the page.tpl.php that I miss, it's more the html.tpl.php, there you can easy add scripts, new css files, arrange the order of them and control a lot what your printing out. 

1.- Do we have in backdrop something like html.tpl.php or everything is controlled from the template.php file? 

2.- Is there a way to customize blocks in a block__5.tpl.php or views in the theme? 

It's true, when you change CMS, all your fast development methods you add archive, like passing a HTML -> Drupal 7 template, if you knew how, was a metter of little time.

 

By the way, I love the fast that Backdrop runs and all the features are just there, so I think onces I master the theming... Backdrop is going to be really fun to work with. 

Thank to all.

 

Derek 

 

 

 

And to add, the system through layouts and custom blocks that build the design of the website in Backdrop to my great joy has nothing to do with bloated visual editors / composers in Wordpress, so you can write short, concise and clever HTML / CSS code and have precise control on the design of the site with pixel accuracy and simplicity without anything superfluous and generated by machine algorithms.