After upgrading to entity API 7.x-1.1 I can no longer override reply.tpl.php in a theme.
i get the error: Cannot use object of type Entity as array in C:\www\sandbox7\includes\common.inc on line 5786
it has to do with the render($content); call, when I comment that out of the template the page loads. But obviously there is no reply content rendered.
when I remove the file from the theme and let it load from the reply module, it works.
I've tried this with several themes and it breaks there too, so its not my custom theme. It happens using bartik.
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | 1994298-32-overriding-reply-tpl.patch | 3.98 KB | Paul B |
| #23 | 1994298-23-whitespace-line-endings-.patch | 24.06 KB | Paul B |
| #20 | reply-cleaneduppatch-1994298-18.patch | 30.1 KB | drupalgideon |
| #18 | 1994298-18-overriding-reply-tpl.patch | 5.34 KB | Paul B |
| #12 | 1994298-10-overriding-reply-tpl_reroll.patch | 3.42 KB | mrharolda |
Comments
Comment #1
Anonymous (not verified) commentedTry this but I'm not sure it will work:
Replace line 784:
with:
Comment #2
loze commentedthanks for the quick reply ivanjaros.
you're on to something but not quite there. This gets rid of the fatal error, but replies are not rendered.
The themes reply.tpl.php is loaded and output, but the render array is not rendered.
it appears that template_preprocess_reply() which sets up that $content variable never fires
And I get the following php warnings:
Thanks for your help on this!
Comment #3
loze commentedI think this may have to do with the theme function being the same name as the entity?
and its possibly colliding with template_preprocess_ENTITY() ?
when I change "reply" to "reply_single" in the hook_theme and the template file name and the preprocess function, it works.
the "Undefined index: #view_mode in template_preprocess_entity()" is what gave me a clue to this.
maybe I've just been looking at this too long. But, it does work the way I've described.
is it possible that the latest version of entity introduced this?
Comment #4
james.williamsThis commit: http://drupalcode.org/project/entity.git/commitdiff/0fb1486b55e1bfae075d... did change something in entity module between 1.0 and 1.1 which might affect things? I'm not sure I understand how the 'patterns' property of the theme hooks works without stepping through the code in heavy detail.
I'm surprised that template_preprocess_entity is being run though here anyway -- that's the bit that I'd want to see investigated, as the reply module should be theming its own entities without the Entity module interfering at that point.
Comment #5
Anonymous (not verified) commentedYeah. It seems they are trying just too much and it's counterproductive.
Comment #6
loze commentedI think this is the root of it http://drupal.org/node/939462 ?
What should we do in the meantime?
Comment #7
loze commentedWe shouldn't need to do this, but setting the 'base hook' in hook_theme_registry_alter() does fix it.
setting it in hook_theme itself did not work.
Comment #8
SebCorbin commentedI think Reply should rely on the basic rendering of entities.
Meaning I'm all for the usage of a wrapper (i.e. theme_replies) but for the inner reply theming we should stick to reply_view().
My problem was that I wanted to add extra_fields to reply entities but hook_entity_view was never fired due to the usage of its own theme function.
What I did :
But I'm still struggling with the way content is handled, render arrays added in $entity->content are not rendered with reply entities this way :
I think this is due to the preprocess function, I'll try to provide a patch
Comment #9
SebCorbin commentedPatch attached
Comment #10
SebCorbin commented'reply' theme key is not necessary anymore as EntityAPI takes care of preprocessing/templating/rendering
Comment #11
mrharolda commentedThe offsets could be due to the fact that I'm using today's -dev instead of a git checkout.
This part of the patch is a bit strange though, did you replace newlines?
Comment #12
mrharolda commentedI've removed
reply.tpl.phpfrom the patch to speed up the process ...Too bad I can't set it to RBTC myself as it works perfectly ;)
Comment #13
SebCorbin commentedYes, there was some problem with line endings. Thanks for the reroll :)
Comment #14
Paul B commentedWith the patch in #12 my reply.tpl.php is missing variables. It seems the _preprocess_reply hooks aren't being run.
Comment #15
mrharolda commented@Paul B, I think you should use TEMPLATE_preprocess_entity(), like all other entities known to Drupal.
Works for me ...
Comment #16
SebCorbin commentedDue to the fact that we delete the 'reply' theme key, you have to work with YOURTHEME_preprocess_entity()
Comment #17
Paul B commentedOK, but one of the variables I'm missing is 'links', which was not set up in my _preprocess_reply() implementations.
It used to be set up by template_preprocess_reply() I believe. That function is not being executed, though template_preprocess_replies() is.
Comment #18
Paul B commentedI guess template_preprocess_reply() should become reply_preprocess_entity(). This patch works for me.
Comment #19
mrharolda commentedOff-topic: Someone should strip all weird line-endings and trailing spaces before we continue fixing this module. Almost half of the patch is unneeded.
Some code style fixes would be great too.
Comment #20
drupalgideonCleaned up version of patch in #18 attached as requested by #19. Run through Coder too .
Comment #21
mrharolda commented@SkidNCrashwell: nice one!
I hope to check it soon, this is quite a welcome patch that really needs to go in -dev asap.
Comment #22
jamesharv commentedThe patch in #18 solved this for me, but the one in #20 wouldn't apply against 7.x-1.x, or against the latest dev release.
Comment #23
Paul B commentedThe patch in #20 seems to be corrupted. Here's a patch that just removes trailing whitespace and converts line endings.
Comment #24
nancydru#1605242: Pass coder review fixes coding styles, please do not mix patches.
Comment #25
nancydruI am very much in favor of #10 or #18 (no other mixed in changes).
Comment #26
Paul B commentedNone of the patches in #10, #18 and #1605242: Pass coder review apply anymore.
The maintainer should give fixing his linebreaks more priority.
Comment #27
Anonymous (not verified) commentedLine endings were fine until one commit(not mine). But I can't find it anymore.Anyway, I won't be committing any new patches until this issue is fixed so I'll wait for RTBC patch.
Sorry, seems the line endings were from my commits, specifically:
http://drupalcode.org/project/reply.git/commitdiff/db507297cc869225c54c3...
and recently http://drupalcode.org/project/reply.git/commit/e37f3028a93ec018dd20f2e36...
which is strange because I haven't change my IDE settings at all. In the second one I was removing a previous commit(ajax functionality) so maybe it has something to do with it but the first one is still a mystery to me.
I'm using Netbeans and it's build-in GIT support. Any tips to avoid this issue again are welcomed.
Comment #28
mrharolda commentedMaybe the 'autocrlf' is missing in your ~/.gitconfig?
Note: this only affects new files, not already commited ones.
https://help.github.com/articles/dealing-with-line-endings
Comment #29
Paul B commentedThis should wait until #2148045 is committed.
Comment #30
nancydru[#2148045) is fixed. Can the submitters re-roll this patch?
Comment #31
Paul B commentedComment #32
Paul B commentedRe-rolled patch.
Comment #33
Paul B commentedComment #34
nancydruClosed #2168819: Trying to get property of non-object in reply_label() as duplicate.
Confirmed that #7 sort of fixes it for me.
Comment #35
josesanmartin commentedThe last patch fixes it for me as well. It's been commited, marking this as fixed.
Comment #37
mihai_brb commentedThis patch messed up the theme for me, as well as reply links (these I noticed).
I did not looked into the code but reverting e350ac727aaeaff51c5d8555822ffec49bff180a fixed it.
Any insight?
Thanks
Comment #38
hyperglide commented@mihai_brb if that is the case you may wish to reopen this issue or perhaps better to create a new issue and link the (2) together.
Comment #39
mihai_brb commentedHello again,
I think the problem is related to the fact that reply entities no longer go trough reply_preprocess_entity and therefor the links and classes are no longer added.
Is there a way to fix this other then adding links in the template for each reply entity?
Maybe use hook_entity_view_alter instead to add those links?
Thanks,
Mihai