Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Existing Content' block doesn't respect theme_hook_suggestions for template file names #2515

Closed
steponeloops opened this issue Feb 3, 2017 · 19 comments

Comments

@steponeloops
Copy link

steponeloops commented Feb 3, 2017

If I add a node to a layout via "Existing content Block" Backdrop pre 1.6.0 renders it in the selected view mode. 1.6.0 doesn't seem to respect the viewmode nor a customized node.tpl.php.
If I add a node to a layout via "Existing content Block" Backdrop pre 1.6.0 used the custom node--nodetype.tpl.php template to render the block. 1.6.0 doesnt'do this anymore.


PR backdrop/backdrop#2663

@herbdool
Copy link

In my testing it does respect the view mode. But what it doesn't respect is the Show author and date information checkbox.

@steponeloops
Copy link
Author

OK, i tested again - it does respect the view mode but still doesn't respect node template overrides in the theme folder.

@steponeloops
Copy link
Author

Further clarifications: still there in 1.6.1.
If I use a generic node.tpl.php in my theme the "existing content" block uses this template override.
But if I try to override a certain content type with node--[contenttype].tpl.php it doesn't work.

@Al-Rozhkov
Copy link
Member

Al-Rozhkov commented Apr 26, 2017

I tested this feature on 2 sites and cannot reproduce. Backdrop 1.6.3

@Al-Rozhkov
Copy link
Member

We have separate issue for "Show author and date information". #2536

Seems like view mode is respected by Existing content block, so I think this issue should be closed.

@steponeloops
Copy link
Author

steponeloops commented May 2, 2017

Sorry, I think I didn't explain myself clearly in the beginning. View modes are respected, but if I try to use a template override (node--[contenttype].tpl.php in the theme folder) this override apparently isn't being used if inserted into the layout as an existing content block.

To me inserting existing nodes with a template override was a convenient way to render sliders etc. on a layout section without the need of specialized display mode modules.

It used to work in 1.5.x versions...

@Al-Rozhkov
Copy link
Member

At first I recommend you to upgrade Backdrop to latest version. It becomes better and better with each release :-)

For me the best tool to debug theme suggestions is Devel module. Usualy I add dpm($variables); in hook_preprocess_node in template.php file of my active theme. That way I can see relevant suggestions for my template files.

@steponeloops let me know if you need more details about debugging with Devel. Or give me more information about your configuration and I try to reproduce it.

@Al-Rozhkov Al-Rozhkov changed the title 1.6.0: Add Existing Content Block doesn't seem to respect Viewmode 1.6.0: Add Existing Content Block doesn't seem to respect theme suggestions May 2, 2017
@herbdool
Copy link

herbdool commented May 2, 2017

I've tested again. I created node--page.tpl.php, added a page node to a layout.

The view modes do work, and node--page.tpl.php can override a standalone node, but node--page.tpl.php is not outputting anything to the node embedded into the layout.

I haven't tried this before so I can't attest to this being the right way to do it, but I can confirm it's not working now.

@herbdool
Copy link

herbdool commented May 2, 2017

I enabled theme debugging (can enable it in system.core.json) and it suggests node--block-##.tpl.php. So I tried that one too but no luck.

@steponeloops
Copy link
Author

@Al-Rozhkov: yes, I would like to upgrade but this one is a showstopper for me as already said I would like to be able to render overridden node templates in layouts so that I won't have to install additional modules if not necessary - a content type with multiple fields, load e.g. the js of slick carousel, make a node, insert it into the layout, slider done.

The best thing in backdrop compared to Drupal to me is that with its layout system it is nearly complete even without additional modules - much easier to maintain :)

Yes I am aware of devel and I use it occasionally - but thank you for your offering to help!

@steponeloops
Copy link
Author

Hello everyone, as this bug seems to be buried I would like to ask a few things: is my method of creating one page layouts (with different "existing content" blocks of different content types) that exotic? To me it seems the easiest way to render different sections such as sliders etc. since I can simply include external libraries such as slick carousel or full page.js - but those libraries of course need html output of a certain structure. And thus the need of "overridable" node templates also in the layout blocks (ie. "Existing Content" blocks).

I know I could use views and views template overrides to achieve this, but for some simpler tasks such as a slider I would prefer this way: just one node with an unlimited image field, no additional modules needed, therefore way less update hassles.

Am I missing some other way to achieve this in a simple manner since this use case seems not very common? :)

It worked until the 1.7.0 update. Unfortunately I am not able to do more than testing and bug reporting - so someone else would have to look into this :(

Is there a chance this bug could be addressed by someone? If I can help (w. further testing etc.) Someone let me know.

@Al-Rozhkov
Copy link
Member

is my method of creating one page layouts

I don't think so. I rarely use it too. And I can confirm this bug.

As quick workaround you can create a view with contextual filter to show single node with particular view mode. It should use proper theme suggestions for nodes.

I wish I can help as soon as possible, but I have very few free time right now.

@Al-Rozhkov Al-Rozhkov self-assigned this Jun 6, 2017
@steponeloops
Copy link
Author

Thanks, Al-Rozhkov. I understand that this is a open source project where many people work in their spare time. I am using views right now! I am happy to hear this issue doesn't get buried tho.

@Al-Rozhkov Al-Rozhkov removed their assignment Dec 23, 2017
@ghost ghost changed the title 1.6.0: Add Existing Content Block doesn't seem to respect theme suggestions 'Existing Content' block doesn't respect theme suggestions Apr 29, 2019
@ghost
Copy link

ghost commented Apr 29, 2019

I'm experiencing this in Backdrop v1.12.6. Trying to override the output of an 'Existing content' block via a theme template (node--block-[NID].tpl.php) doesn't work.

Code is here: https://api.backdropcms.org/api/backdrop/core%21modules%21node%21node.block.inc/function/NodeBlock%3A%3AgetContent/1

@herbdool
Copy link

@BWPanda does either node--[type].tpl.php or node--[nodeid].tpl.php work? Some people report the former doesn't work.

@ghost
Copy link

ghost commented May 13, 2019

@herbdool
node--[type].tpl.php works for overriding the nodes themselves, but not when viewed in a block.
node--[nodeid].tpl.php works for both overriding the nodes themselves and also when viewed in a block.

@herbdool
Copy link

@BWPanda PR for testing backdrop/backdrop#2663

From looking at the code and the theme debug suggestions, only node--block-NID.tpl.php is supported. So I think my PR fixes the problem @BWPanda mentions. node--CONTENTTYPE.tpl.php is not suggested so I don't know if that part is a bug and can't confirm that it ever worked in Backdrop. If people want it, I suppose that could be a new feature issue.

@herbdool herbdool added this to the 1.12.7 milestone May 13, 2019
@ghost
Copy link

ghost commented May 13, 2019

@herbdool Brilliant! That fixed the issue. Now I feel bad that I didn't even bother trying to find and fix it myself since it was so simple ;-)

@jenlampton jenlampton changed the title 'Existing Content' block doesn't respect theme suggestions 'Existing Content' block doesn't respect theme_hook_suggestions for template file names May 15, 2019
@quicksketch
Copy link
Member

Wow nice one. Thanks @herbdool, @BWPanda, @steponeloops, and @Al-Rozhkov for working (and waiting) to fix this one together! Merged backdrop/backdrop#2663 into 1.x and 1.12.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants